- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, I am a student researcher new to SGX, which is used in my project. I need to create a random number using sgx_read_rand. When I try to I receive the error LNK2019 unresolved external symbol _sgx_read_rand referenced in function _main. I have added #include<sgx_trts.h>. I have also tried adding sgx_trts.lib into the additional dependencies, but I still get the same error. I am using Visual Studio 2015. Any help is appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Giovanni,
You need to create an enclave call (ecall) that your untrusted app can call. The SGX101 enclave_example is a simple tutorial on creating an enclave with a single ecall and ocall, which is based on the SampleEnclave in the SGX SDK. You should be able to easily modify this code for your purposes.
Refer to the section Enclave Development Basics in the Intel SGX SDK Developer Reference Guide for Windows for complete details on ecalls, ocalls, and other topics you should know when developing SGX applications.
Sincerely,
Jesus G.
Intel Customer Support
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Giovanni,
Can you run any of the SGX SDK samples successfully? Try compiling and running SampleEnclave.
If you can run SampleEnclave successfully, then ensure your project settings match the project settings from SampleEnclave.
I was able to use sgx_read_rand by adding #include <sgx_trts.h> and no other modifications.
Sincerely,
Jesus G.
Intel Customer Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I should have mentioned that I ran it in simulation mode. Yes I can run the SampleEnclave, in simulation mode. How can I make sure that the project settings match the project settings of the SamepleEnclave. Could it be that sgx_read_rand does not work in simulation mode?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Giovanny,
I confirmed that sgx_read_rand works in Simulation mode.
Refer to Unable to Build a Custom Intel® Software Guard Extensions (Intel® SGX) Application in Visual Studio* to configure the correct settings for your project.
Sincerely,
Jesus G.
Intel Customer Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, I tried those options and they didn't work for me. I am now using the sample enclave as my base and it runs, but when I try to use sgx_read_rand I still get
Error LNK2019 unresolved external symbol _sgx_read_rand referenced in function _main
as well as
Error LNK1120 1 unresolved externals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Giovanni,
If you are using the SampleEnclave in Simulation mode, added #include <sgx_trts.h> and you still get the linker error, then the only other variable I see is the version of Visual Studio you are using. The SGX SDK was validated with Visual Studio 2019 and Visual Studio 2015 is not supported. Try updating to Visual Studio 2019 and re-run your tests.
Sincerely,
Jesus G.
Intel Customer Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Giovanni,
Do you still need help with this issue?
Sincerely,
Jesus G.
Intel Customer Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, Yes I do. I have upgraded to Visual Studio 2019. I am still getting the same error
LNK2019 Unresolved external symbol_sgx_read_rand referenced in function _main
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Giovanni,
Below are screenshots of my dev environment that may help you. I just noticed you wrote that you are getting that error from function _main. Are you trying to use sgx_read_rand in the untrusted app or the enclave? It cannot be used in the main app, it must be called from within the enclave because it is a trusted function.
This is the code I added to SampleEnclave/Enclave/Enclave.cpp:
#include "sgx_trts.h"
....
unsigned char rand_num[4] = "AAA";
sgx_status_t rand_ret = sgx_read_rand(rand_num, sizeof(rand_num));
if (rand_ret == SGX_SUCCESS) printf("Rand Success\n");
Loaded DLLs:
Enclave Project Properties:
Sincerely,
Jesus G.
Intel Customer Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Giovanni,
Do you still need help with this issue?
Sincerely,
Jesus G.
Intel Customer Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much. I was trying to use sgx_read_rand in the applications main. I placed it in the printf function of the SampleEnclave Enclave.cpp and it reported Rand Success. I am now having trouble figuring out how to create my own function in the Enclave.cpp that will return the random number once called from the applications main.
What I am asking is, how do I create a function in the enclave.cpp that I can call from the application main. I have not figured it out with the documentation that I have read so far. Could you help me with this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Giovanni,
You need to create an enclave call (ecall) that your untrusted app can call. The SGX101 enclave_example is a simple tutorial on creating an enclave with a single ecall and ocall, which is based on the SampleEnclave in the SGX SDK. You should be able to easily modify this code for your purposes.
Refer to the section Enclave Development Basics in the Intel SGX SDK Developer Reference Guide for Windows for complete details on ecalls, ocalls, and other topics you should know when developing SGX applications.
Sincerely,
Jesus G.
Intel Customer Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This thread has been marked as answered and Intel will no longer monitor this thread. If you want a response from Intel in a follow-up question, please open a new thread.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page