I've been trying to use the protected_fs API from SGX within a test enclave project. The enclave finds the header file just fine, but when instructing the linker to link against -lsgx_tprotected_fs I get a whole lot of undefined reference errors. My experience in Linux development is close to 0, I would suspect something went wrong in building sgx_tprotected_fs.a, but really no idea.
How can I resolve this?
The enclave linker flags:
The gcc output:
Hi Marion M:
As I can see, all undefined reference starts with "u_", so did you link the untrusted part with-lsgx_uprotected_fs? Check it !
I have write a very simple demo about how to use protected_fs API : https://github.com/light1021/SGX-protected-fs-demo . You can make a reference to it.
Many thanks for the quick reply! I indeed had not linked the lsgx_uprotected_fs lib, awesome. I found some other things I was missing in your sample code too, again aweseome. I still cant compile now though, for another set of undefined references that seem.. C++ related. Do you maybe have a clue what is wrong here too?
I have never see this error before. Can your share the content of “lru_cache.cpp" ? It seems like you enclave didn't link some library that lru_cache need.
I'm sorry. I find that Lru_cache is a part of protected_fs. It seems that "std::__1::__* " is not a part of stdc++. Lru uses libc++ you can install it by run "apt install libc++-dev", Then you need to add -lc++ in your enclave link flag.Try it！
$(Enclave_Name): $(Enclave_C_Objects) enclave_t.o @echo $^ @$(CC) $^ -o $@ $(Enclave_Link_Flags) -lc++ @echo "LINK => $@"
I found this other thread https://software.intel.com/en-us/forums/intel-software-guard-extensions-intel-sgx/topic/711404https://software.intel.com/en-us/forums/intel-software-guard-extensions-intel-sgx/topic/711404
which seems to talk about the same issue. I did change my stdlib to sgx_tcxx.lib and now it compiles fine. I'll switch to your proposed solution though and see how this works out, many thanks!