cuda opencv未定义对`nppiConvert_16u8u_C4R`的引用

时间:2015-03-11 00:24:07

标签: c++ opencv cuda npp

我正在尝试将基于opencv的简单rgb运行到灰度级脚本并通过cuda运行它。执行计算的C ++脚本的标题链接来自opencv的以下api:

#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 cudaLinking 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&)'

我对此很新,因为我不确定在哪里寻找解决此错误。

编辑: 1.在评论之后,我在添加LIB路径后将lnppi选项添加到main中(请参阅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'
  1. 通过lz
  2. 添加了指向zlib的链接

1 个答案:

答案 0 :(得分:2)

尝试使用OPENCV_PATH/3rdparty/lib下OpenCV的-libIlmImf -llibjpeg -llibjasper -llibpng -lzlib文件夹下的附加库。 还要注意链接库的顺序,因为任何静态库必须以适当的顺序链接,否则将使用GNU ld显示未解析的引用:

  

如果任何[静态] 库A 依赖于库B 中定义的符号,   那么库A 应首先出现在提供给链接器的列表中。

有关详细信息,请参阅linker order - GCC