Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to `cv::imwrite #206

Closed
xwang365 opened this issue Sep 8, 2022 · 4 comments
Closed

undefined reference to `cv::imwrite #206

xwang365 opened this issue Sep 8, 2022 · 4 comments

Comments

@xwang365
Copy link

xwang365 commented Sep 8, 2022

尝试跑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

@jiangjiajun
Copy link
Collaborator

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

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

@xwang365
Copy link
Author

xwang365 commented Sep 9, 2022

参考了: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

@jiangjiajun
Copy link
Collaborator

jiangjiajun commented Sep 9, 2022

@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
Copy link
Collaborator

此ISSUE由于一年未更新,将会关闭处理,如有需要,可再次更新打开。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants