我正在尝试运行基于 opencv 的简单 rgb 到灰度脚本并通过 cuda 运行它。执行计算的 C++ 脚本的标头链接以下 api opencv
:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
我正在尝试使用以下makefile
逻辑对其进行编译:
OPENCV_LIBPATH=-L/apps/gcc/4.7.2/opencv/2.4.8/lib
OPENCV_LIBPATH += -l/opt/cuda/5.5/lib64
OPENCV_INCLUDEPATH=/apps/gcc/4.7.2/opencv/2.4.8/include
OPENCV_LIBS=-lopencv_core -lopencv_imgproc -lopencv_highgui -lnppi -lz
CUDA_INCLUDEPATH=/opt/cuda/5.5/include
NVCC_OPTS=-O3 -arch=sm_20 -Xcompiler -Wall -Xcompiler -Wextra -m64
GCC_OPTS=-O3 -Wall -Wextra -m64
main: rgbtogrey.o rgb_to_grey.o Makefile
$(NVCC) -o main.out rgbtogrey.o rgb_to_grey.o -I$(OPENCV_INCLUDEPATH) $(OPENCV_LIBPATH) $(OPENCV_LIBS)
rgbtogrey.o: rgbtogrey.cpp timer.h utils.h
g++ -c rgbtogrey.cpp $(GCC_OPTS) -I $(CUDA_INCLUDEPATH) -I $(OPENCV_INCLUDEPATH)
rgb_to_grey.o: rgb_to_grey.cu utils.h
nvcc -c rgb_to_grey.cu $(NVCC_OPTS)
clean:
rm -f *.o hw
我尝试了许多其他解决方案,例如 Compiling a basic opencv cuda 和Linking Cuda in C++ issue概述的解决方案。
当前错误:
/apps/gcc/4.7.2/opencv/2.4.8/lib/libopencv_highgui.a(grfmt_exr.cpp.o): In function `cv::ExrDecoder::ExrDecoder()':
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoderC2Ev+0x9d): undefined reference to `Imf::Chromaticities::Chromaticities(Imath::Vec2<float> const&, Imath::Vec2<float> const&, Imath::Vec2<float> const&, Imath::Vec2<float> const&)'
我对此很陌生,因此不确定在哪里寻找解决此错误的方法。
lnppi
编辑: 1. 在添加 LIB 路径后,我在注释之后将选项添加到主目录(请参阅更新的 makefile 部分)
现在错误:
/apps/gcc/4.7.2/opencv/2.4.8/lib/libopencv_core.a(persistence.cpp.o): In function `icvGets(CvFileStorage
persistence.cpp:(.text._ZL7icvGetsP13CvFileStoragePci+0x127): undefined reference to `gzgets'
- 通过添加到 zlib 的链接
lz