【发布时间】:2019-05-27 13:35:34
【问题描述】:
我已经看到了许多解决该问题的方法,但没有人帮助我。
我尝试在 Makefile 中添加 opencv_imgcodecs,使用 cmake 等。
Makefile.config
CPU_ONLY := 1
OPENCV_VERSION := 3
CUSTOM_CXX := g++
CUDA_DIR := /usr/local/cuda
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_61,code=compute_61
BLAS := atlas
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include
PYTHON_LIB := /usr/lib
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
BUILD_DIR := build
DISTRIBUTE_DIR := distribute
TEST_GPUID := 0
Q ?= @
当我执行 make all 时,我在输出中收到下一个错误:
CXX/LD -o .build_release/tools/extract_features.bin
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::String::allocate(unsigned long)'
.build_release/lib/libcaffe.so: undefined reference to `cv::String::deallocate()'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status
Makefile:635: recipe for target '.build_release/tools/extract_features.bin' failed
make: *** [.build_release/tools/extract_features.bin] Error 1
Ubuntu 18.04。 那是我使用的最后一个指南Here
从输出来看:
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
CXX tools/extract_features.cpp
CXX/LD -o .build_release/tools/extract_features.bin
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
看来我们要去动态库libcaffe.so 并在我们使用它与extract_features.bin 交互之后。如果您要了解 libcaffe.so 编译自的内容,也许可以在任何源文件中包含 OpenCV 连接。
但是如何确定创建libcaffe.so的源文件我不明白。
我试图查看Makefile,感觉好像他被混淆了,什么都不清楚。
【问题讨论】:
-
一点建议?
-
遇到了同样的问题?任何解决方案@AlmostAI
-
@KhanHafizurRahman 为我的案例添加了解决方案