gpt4 book ai didi

OpenCV 构建对从源构建的 protobuf 的 undefined reference

转载 作者:太空宇宙 更新时间:2023-11-03 23:16:38 60 4
gpt4 key购买 nike

我正在尝试从源代码构建 OpenCV。我已将 protobuf 安装到我的主目录;它是用 --enable-shared build 的. LD_LIBRARY_PATH$HOME/lib在头部; LIBRARY_PATHLD_RUN_PATH设置为 $LD_LIBRARY_PATH , 和 CPATH设置为 $HOME/include . PKG_CONFIG_PATH$HOME/lib/pkgconfig .

以下是一些相关的版本:

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 访问权限。所以我不确定解决方法是什么。

最佳答案

我最近遇到了同样的问题,因为我安装了最新的 protobuf (3.1.0) 并使用 GCC 4.9 构建了我的 opencv。当我切换回 GCC 5 时,OpenCV 3.1 可以成功构建。

如果你想将 Matlab 与 OpenCV 3.1 一起使用,我认为你可能需要降级你的 protobuf 版本,如 protobuf-2.5.0,然后你可以使用 GCC 4.9 重建 OpenCV。

关于OpenCV 构建对从源构建的 protobuf 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38111996/

60 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com