Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/161.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 生成OpenCV时出错:“引用”;使用-fPIC“重新编译”;_C++_Linux_Opencv_Makefile_Ant - Fatal编程技术网

C++ 生成OpenCV时出错:“引用”;使用-fPIC“重新编译”;

C++ 生成OpenCV时出错:“引用”;使用-fPIC“重新编译”;,c++,linux,opencv,makefile,ant,C++,Linux,Opencv,Makefile,Ant,在本指南的帮助下,我正在Linux上安装OpenCV 在最后一步,我得到了以下错误。我曾尝试在cmakegui中添加fPIC,但仍然没有解决问题。在cmake gui中,我创建了一个新的名称值条目:CXX\u FLAG-fPIC——不确定这样做是否正确 make -j Linking CXX shared library ../../lib/libopencv_java331.so /usr/bin/ld: CMakeFiles/opencv_java.dir/generator/src/cp

在本指南的帮助下,我正在Linux上安装OpenCV

在最后一步,我得到了以下错误。我曾尝试在cmakegui中添加
fPIC
,但仍然没有解决问题。在cmake gui中,我创建了一个新的名称值条目:
CXX\u FLAG-fPIC
——不确定这样做是否正确

make -j

Linking CXX shared library ../../lib/libopencv_java331.so
/usr/bin/ld: CMakeFiles/opencv_java.dir/generator/src/cpp/listconverters.cpp.o: relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
CMakeFiles/opencv_java.dir/generator/src/cpp/listconverters.cpp.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libopencv_java331.so] Error 1
make[1]: *** [modules/java/CMakeFiles/opencv_java.dir/all] Error 2
make: *** [all] Error 2
更新:
cmake gui中的正确标志是cmake_CXX_标志。在
配置、生成并生成-j

确定后,仍然会出现错误。这是对我有用的东西

$ export JAVA_HOME=/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64 //replace with your JDK path
$ git clone https://github.com/opencv/opencv.git
$ cd opencv
$ mkdir build
$ cd build
$ cmake -D BUILD_SHARED_LIBS=OFF -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=. ..
$ make -j

BUILD SUCCESSFUL
Total time: 10 seconds