Opencv2.4链接CUDA9.0产生依赖问题

问题1: opencv编译的时候,报错如下

/usr/bin/ld: cannot find -lopencv_dep_nppial
/usr/bin/ld: cannot find -lopencv_dep_nppicc
/usr/bin/ld: cannot find -lopencv_dep_nppicom
/usr/bin/ld: cannot find -lopencv_dep_nppidei
/usr/bin/ld: cannot find -lopencv_dep_nppif
/usr/bin/ld: cannot find -lopencv_dep_nppig
/usr/bin/ld: cannot find -lopencv_dep_nppim
/usr/bin/ld: cannot find -lopencv_dep_nppist
/usr/bin/ld: cannot find -lopencv_dep_nppisu
/usr/bin/ld: cannot find -lopencv_dep_nppitc
collect2: error: ld returned 1 exit status

1.将Opencv的cmake改为以下修改好的cmake:
https://download.csdn.net/download/hansry/11215024

2.修改文件./opencv-2.4.12/modules/gpu/src/graphcuts.cpp,将大概在45行的地方
// #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
改为
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 9000)

mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CUDA_GENERATION=Kepler -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j4 
sudo make install 

问题2: 其他库链接opencv的时候,同样会出现

   /usr/bin/ld: cannot find -lopencv_dep_nppial
    /usr/bin/ld: cannot find -lopencv_dep_nppicc
    /usr/bin/ld: cannot find -lopencv_dep_nppicom
    /usr/bin/ld: cannot find -lopencv_dep_nppidei
    /usr/bin/ld: cannot find -lopencv_dep_nppif
    /usr/bin/ld: cannot find -lopencv_dep_nppig
    /usr/bin/ld: cannot find -lopencv_dep_nppim
    /usr/bin/ld: cannot find -lopencv_dep_nppist
    /usr/bin/ld: cannot find -lopencv_dep_nppisu
    /usr/bin/ld: cannot find -lopencv_dep_nppitc
    collect2: error: ld returned 1 exit status

解决办法为将cuda的相关库拷贝到/usr/local/lib中,如
sudo cp /usr/local/cuda-9.0/libnppc.so.9.0 /usr/local/lib/libopencv_dep_nppc.so

参考:https://blog.csdn.net/u012477435/article/details/80776613

你可能感兴趣的:(Ubuntu)