Intel® Software Guard Extensions (Intel® SGX)
Discussion board focused on hardware-based isolation and memory encryption to provide extended code protection in solutions.

Adding OpenCV libraries in SGX-Enclave Project

Shezan__Faysal_Hossa
848 Views


I am trying to add OpenCV in my enclave project. I can run the OpenCV project as a standalone win32 console application in visual studio 2015. But when I started doing that in my enclave project I am getting errors. I tried to add the following libraries from opencv in enclave project:

#include "windows.h"
#include <opencv2/core/core.hpp>
#include "opencv2/imgcodecs.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/face.hpp>
#include "drawLandmarks.hpp"

But I am getting tons of error. I also need to include windows.h file in my project. Are those libraries are allowed to include in the enclave project?

0 Kudos
3 Replies
Francisco_C_Intel
848 Views

I'm not familiar enough with the OpenCV headers, but for sure you cannot include the Windows headers.

In general, you can't make any system calls inside an enclave.

The developer reference has more details on which APIs are / are not allowed.

0 Kudos
Shezan__Faysal_Hossa
848 Views

Thank you for your comment. But do you know whether SGX-Enclave supports OpenCV or not? Because from my understanding, I think they only provide support for OpenSSl (if I am not wrong). I got this idea by visiting their download center :- https://software.intel.com/en-us/sgx-sdk/download

0 Kudos
Shezan__Faysal_Hossa
848 Views

I followed the following steps while adding opencv static library in the project:- 


1. Generated the OpenCV static library using CMake,

2. Added the following values in the inlucde directories :-
 
C:\Program Files (x86)\Intel\IntelSGXSDK\include
C:\Program Files (x86)\Intel\IntelSGXSDK\include\libc++
C:\Program Files (x86)\Intel\IntelSGXSDK\include\tlibc
C:\Users\fs5ve\Downloads\Opencv-static\static\opencv\include
C:\Users\fs5ve\Downloads\Opencv-static\static\opencv\build-32-extra\install\include
C:\Users\fs5ve\Downloads\Opencv-static\static\opencv\build-32-extra\install\include\opencv
C:\Users\fs5ve\Downloads\Opencv-static\static\opencv\build-32-extra\install\include\opencv2
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
%(AdditionalIncludeDirectories)

3. Added the following value in additional library directories:-

   $(SGXSDKInstallPath)bin\$(Platform)\Debug;C:\Users\fs5ve\Downloads\Opencv-static\static\opencv\build-32-extra\install\x86\vc14\staticlib
 
4. Added the following values in the addtional dependecies :-


sgx_trts_sim.lib

sgx_tstdc.lib
sgx_tservice_sim.lib
sgx_tcrypto.lib
sgx_tcxx.lib
sgx_urts_sim.lib
sgx_uae_service_sim.lib
opencv_calib3d400d.lib
opencv_core400d.lib
opencv_highgui400d.lib
opencv_face400d.lib
opencv_features2d400d.lib
opencv_flann400d.lib
opencv_imgcodecs400d.lib
opencv_imgproc400d.lib
opencv_ml400d.lib
opencv_objdetect400d.lib
opencv_photo400d.lib
opencv_shape400d.lib
opencv_stitching400d.lib
opencv_superres400d.lib
opencv_video400d.lib
opencv_videoio400d.lib
opencv_videostab400d.lib


I am getting the following error:-
Cannot open include file: 'emmintrin.h': No such file or directory

I have added "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include"  in the Include directories. But after that I am getting the following error:-
Cannot open include file: 'malloc.h': No such file or directory
0 Kudos
Reply