- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Managed to get it working by creating a fresh project with the following:
- project properties -> c/c++ build -> settings -> tool settings -> preprocessor -> additional include directories:
/home/mninicfe/OpenCV_intel/opencv-3.0.0/IntelBuild/ install/include/opencv
/home/mninicfe/OpenCV_intel/opencv-3.0.0/IntelBuild/ install/include - project properties -> c/c++ build -> settings -> tool settings -> libraries-> additional libraries:
opencv_core
opencv_imgcodecs
opencv_highgui
opencv_imgproc - project properties -> c/c++ build -> settings -> tool settings -> libraries-> additional libraries:
/home/mninicfe/OpenCV_intel/opencv-3.0.0/IntelBuild/ install/lib - project properties -> c/c++ build -> settings -> tool settings -> code generation -> tick "Generate Position Independant Code (-fpic)
- run configurations -> c++ aplication -> Arguments: lena.jpg
- run configurations -> c++ aplication -> environment -> LD_LIBRARY_PATH | /home/mninicfe/OpenCV_intel/
opencv-3.0.0/IntelBuild/ install/lib/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Produce a shared object which can then be linked with other objects to form an executable. Not all systems support this option. For predictable results, you must also specify the same set of options used for compilation (-fpic, -fPIC, or model suboptions) when you specify this linker option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yeah i forgot to add maybe the most important thing in the post above:
- Eclipse -> project properties -> c/c++ build -> settings -> tool settings -> code generation -> tick "Generate Position Independant Code (-fpic)
It's edited and added now. Problem solved, you can close this topic :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's a good point, Judy.
@zvonimir: Great to know it's resolved and yes will close this thread, appreciate much. -Kittur

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page