Hello
I am trying to run a test program using ICC in Eclipse. I previously ran the same program with GCC and it worked fine but now when I am building it with ICC and ICC built OpenCV libraries I get the following error:
**** Incremental Build of configuration Debug for project DisplayImage_Intel ****
make all
Building target: libDisplayImage_Intel.so
Invoking: Intel C++ Linker
icpc -L/home/mninicfe/OpenCV_intel/opencv-3.0.0/IntelBuild/install/lib/ -shared -o "libDisplayImage_Intel.so" ./src/DisplayImage_Intel.o -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_highgui
ld: ./src/DisplayImage_Intel.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
./src/DisplayImage_Intel.o: could not read symbols: Bad value
make: *** [libDisplayImage_Intel.so] Error 1
My program code looks like this:
//#include <cv.h>
//#include <highgui.h>
#include <opencv2/opencv.hpp>
#include <stdio.h>
using namespace cv;
int main( int argc, char** argv )
{
Mat image;
image = imread( argv[1], 1 );
if( argc != 2 || !image.data )
{
printf( "No image data \n" );
return -1;
}
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
imshow( "Display Image", image );
waitKey(0);
return 0;
}
I tried to solve this problem by adding these flags and building OpenCV from the beginning but it didn't help:
COMPILE_FLAGS+=-fPIC
export CFLAGS="$CFLAGS -fPIC"
export CXXFLAGS="$CXXFLAGS -fPIC"
Any help would be appreciated.
Link Copied
Managed to get it working by creating a fresh project with the following:
I think -fPIC needs to be added to the linker flags also, i.e. from https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html:
-shared
Yeah i forgot to add maybe the most important thing in the post above:
It's edited and added now. Problem solved, you can close this topic :)
That's a good point, Judy.
@zvonimir: Great to know it's resolved and yes will close this thread, appreciate much. -Kittur
For more complete information about compiler optimizations, see our Optimization Notice.