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

cuda opencv undefined reference to `nppiConvert_16u8u_C4R`

我正在尝试 运行 基于 opencv 的简单 rgb 到灰度脚本并通过 cuda 运行 它。执行计算的 C++ 脚本的 header link 是来自 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 cuda and 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&)'

我对此很陌生,因此不确定到哪里寻找解决此错误的方法。

编辑: 1.根据评论,我在添加 LIB 路径后向主选项添加了 lnppi 选项(请参阅已更新的 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. 添加 link 到 zlib

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

If any [static] library A depends on symbols defined in library B, then library A should appear first in the list supplied to the linker.

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