Galaxy
Galaxy

Reputation: 873

Error when Installing OpenCV 2.4.11 in Centos

I followed the instructions online to install OpenCV 2.4.11 in Centos. But I got an error in the step of make && make install.

Here it is:

Linking CXX shared library ../../lib/libopencv_core.so
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libstdc++.a(ctype.o): relocation R_X86_64_32S against `vtable for std::ctype<wchar_t>' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/libstdc++.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [lib/libopencv_core.so.2.4.11] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [all] Error 2

Does anyone know what's wrong with my libstdc++.a?

Upvotes: 1

Views: 256

Answers (1)

mandaleeka
mandaleeka

Reputation: 6667

Based on the error message, I think the problem is that your static libstdc++ is compiled without the -fPIC option, so ld doesn't want to make a shared object with it.

The -fPIC option generates position independent code that has extra information that lets it be mapped into different memory addresses without having to change (this is why ld is complaining when you try to make a shared object using code that is not position-independent).

You can fix this by getting (or building) a libstdc++ that is built with -fPIC.

Upvotes: 1

Related Questions