FastDeploy icon indicating copy to clipboard operation
FastDeploy copied to clipboard

undefined reference to `cv::imwrite

Open xwang365 opened this issue 1 year ago • 3 comments

尝试跑C++ 推理示例 报错 gcc demo.cpp
-I./FastDeploy/build/fastdeploy-0.0.3/include/
-I./FastDeploy/build/fastdeploy-0.0.3/third_libs/install/opencv/include/
-I./FastDeploy/build/third_libs/install/opencv/include/
-lfastdeploy
-lopencv_core
-lstdc++
-ldl
-o demo.so \

/usr/bin/ld: /tmp/ccxAZsgp.o: in function main': demo.cpp:(.text+0x1b1): undefined reference to cv::imread(cv::String const&, int)' /usr/bin/ld: demo.cpp:(.text+0x2a0): undefined reference to `cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator > const&)' collect2: error: ld returned 1 exit status make: *** [Makefile:2: demo.so] Error 1

xwang365 avatar Sep 08 '22 08:09 xwang365

需要通过-L将lib路径加进来

建议参考example目录下的示例使用cmake

jiangjiajun avatar Sep 08 '22 11:09 jiangjiajun

参考了:FastDeploy/examples/vision/classification/paddleclas/cpp/README.md 这里的例子,同样也遇到了问题:1. https://bj.bcebos.com/paddlehub/fastdeploy/libs/0.2.0/fastdeploy-linux-x64-gpu-0.2.0.tgz 地址失效,换成https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-linux-x64-0.2.0.tgz 可以解决,2.跑 ./infer_demo ResNet50_vd_infer ILSVRC2012_val_00000010.jpeg 0 的时候 会报错./infer_demo: error while loading shared libraries: libpaddle2onnx.so.1.0.0rc3: cannot open shared object file: No such file or directory

xwang365 avatar Sep 09 '22 08:09 xwang365

@xwang365 Hi,谢谢你的反馈,这页文档地址先前确实写错了,已修改。

Linux下编译生成二进制后,如果执行出现上面的问题,属于库没找到的问题,你可以试下把库加到LD_LIBRARY_PATH中执行 例如

export LD_LIBRARY_PATH=/fastdeploy-linux-x64-0.2.0/third_libs/install/paddle2onnx/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/fastdeploy-linux-x64-0.2.0/third_libs/install/onnxruntime/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/fastdeploy-linux-x64-0.2.0/third_libs/install/opencv/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/fastdeploy-linux-x64-0.2.0/third_libs/install/paddle_inference/paddle/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/fastdeploy-linux-x64-0.2.0/third_libs/install/paddle_inference/third_party/install/mklml/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/fastdeploy-linux-x64-0.2.0/third_libs/install/paddle_inference/third_party/install/mkldnn/lib:${LD_LIBRARY_PATH}

通过如上方式,将FastDeploy中的库路径添加好,即可执行。

jiangjiajun avatar Sep 09 '22 10:09 jiangjiajun