Ask Your Question
0

How can I solve this error while making OpenCV3.2 on ubuntu16.04?

asked 2017-03-04 23:49:25 -0600

chenzhuo gravatar image

updated 2017-03-05 09:35:58 -0600

I'm trying to compile OpenCV3.2 , but unfortunately I got this error , and I had done lots of work to solve it but failed,.

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_EXTRA_MODULES_PATH=/home/chenzhuo/opencv_contrib/modules -D PYTHON_EXECUTABLE=/usr/bin/python -D BUILD_EXAMPLES=ON ..

[ 84%] Built target example_structured_light_projectorcalibration
[ 84%] Linking CXX shared module ../../lib/cv2.so
 /usr/bin/ld: CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o: relocation R_X86_64_PC32 against undefined symbol `_Z13pyopencv_fromIN2cv4MatxIdLi4ELi4EEEEP7_objectRKT_' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
modules/python2/CMakeFiles/opencv_python2.dir/build.make:394: recipe for target 'lib/cv2.so' failed
make[2]: *** [lib/cv2.so] Error 1
CMakeFiles/Makefile2:20459: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/all' failed
make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-03-05 03:39:08 -0600

Kerry gravatar image

Just as an alternative way of building have you tried building the libraries using the Maven build process? This is under the directory <open_CV_root>/platforms/maven.

You will need to first ensure Java and Maven are installed on ubuntu but you can use the repo defaults for that. There is also a ReadMe in the directory too.

edit flag offensive delete link more

Comments

I haven't tried building the libraries using the Maven build process , but if I use this process, can I do my jobs with python ? Because I am not good at Java.

chenzhuo gravatar imagechenzhuo ( 2017-03-05 08:36:07 -0600 )edit

You don't need to be write any Java, Maven is a build tool. By default the OpenCV Maven build file (the POM) will build the OpenCV python bindings. You will have to install both the JDK and maven but this can be easily done using aptitude on the commandline : sudo aptitude install default-jdk and sudo aptitude install maven. Once you have those installed go to the maven directory mentioned in my answer and issue the build command to Maven: mvn clean install (no NOT execute this as sudo). I believe the python binding library is cv2.so and it is under the directory build/lib. Please make sure you read the README in that directory too.

Kerry gravatar imageKerry ( 2017-03-05 09:38:50 -0600 )edit

Thanks a lot , I have compiled and installed OpenCV

chenzhuo gravatar imagechenzhuo ( 2017-03-06 04:00:32 -0600 )edit

If it worked, could you mark my answer as correct please? Thanks.

Kerry gravatar imageKerry ( 2017-03-07 13:50:41 -0600 )edit

emphasized textnforcer-plugin/1.4.1/maven-enforcer-plugin-1.4.1.jar (27 KB at 14.4 KB/sec) [WARNING] The POM for com.googlecode.cmake-maven-project:cmake-maven-plugin:jar:3.4.1-b2-SNAPSHOT is missing, no dependency information available

when run commands as given in the answer and commnet .i get taht error. how to get rid of it?.i have installed the jdk and maven.

hls gravatar imagehls ( 2017-03-08 15:15:07 -0600 )edit

hls, you should raise your comment as a separate question on here as it's unrelated to the original posting.

Kerry gravatar imageKerry ( 2017-03-10 15:34:24 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-03-04 23:49:25 -0600

Seen: 1,110 times

Last updated: Mar 05 '17