私はソースからOpenCVを構築しようとしています。私は私のホームディレクトリにprotobufをインストールしました。それは--enable-shared
で建設されました。 LD_LIBRARY_PATH
の頭には$HOME/lib
があります。 LIBRARY_PATH
およびLD_RUN_PATH
は、$LD_LIBRARY_PATH
に設定され、CPATH
は、$HOME/include
に設定されます。 PKG_CONFIG_PATH
は$HOME/lib/pkgconfig
になります。OpenCVはソースからビルドされたprotobufへの未定義参照を構築します
opencv==3.1.0
gcc==4.8.5
g++==4.8.5
python==3.5.2
protobuf==2.6.1
私のcmakeのコマンドは
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$HOME -D OPENCV_EXTRA_MODULES_PATH=$HOME/opencv_contrib-3.1.0/modules -D PYTHON_DEFAULT_EXECUTABLE=$HOME/bin/python -D CMAKE_PREFIX_PATH=$HOME ..
cmakeのが成功したとさえ、それは<~>/lib/libprotobuf.so
でいるProtobufを見つけたと言うである:ここでは
は、いくつかの関連バージョンです。しかしmakeはそれを見つけることができません。
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)'
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::internal::InitEmptyString()'
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::internal::empty_string_once_init_'
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::internal::empty_string_'
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::io::CodedInputStream::BytesUntilTotalBytesLimit() const'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/opencv_test_dnn] Error 1
make[1]: *** [modules/dnn/CMakeFiles/opencv_test_dnn.dir/all] Error 2
他の場所のカップルがいるProtobufの複数のバージョンが問題を引き起こす可能性があることに言及します。 は/lib64の別のprotobufですが、私はrootアクセス権がないので削除できません。だから私は回避策が何であるか分かりません。
私はGCC 4.8.5または4.9で同じ問題を抱えていますが、openCVはgcc 5.4でOKです。残念ながらMatlabはGCC 5を正式にサポートしていないため、以前のGCCでビルドする必要があります – Blaze