2

Hi I am trying to compile a OpenCV (2.6.4) CUDA program on my Win7 Visual Studio, using static link in order to allow the program to run on another computer without CUDA/OpenCV installed. I think i got pretty close but I get stuck in these errors:

1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_8s_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_8s_C2R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_8s_C3R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_8s_C4R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_8u_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_8u_C4R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_16u_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_16u_C2R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_16u_C4R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_16s_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_16s_C2R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_16s_C4R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_32s_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_32s_C4R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_32f_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_32f_C4R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_8u_C1MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_8u_C4MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_16u_C1MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_16u_C4MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_16s_C1MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_16s_C4MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_32s_C1MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_32s_C4MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_32f_C1MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiSet_32f_C4MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_8u_C1MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_8u_C3MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_8u_C4MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_16u_C1MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_16u_C3MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_16u_C4MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_16s_C1MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_16s_C3MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_16s_C4MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_32s_C1MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_32s_C3MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_32s_C4MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_32f_C1MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_32f_C3MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiCopy_32f_C4MR
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_8u16u_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_8u16u_C4R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_8u16s_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_8u16s_C4R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_8u32f_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_16u32s_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_16u32f_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_16s32s_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_16s32f_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_16u8u_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_16u8u_C4R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_16s8u_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_16s8u_C4R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_32f8u_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_32f16u_C1R
1>opencv_core246.lib(gpumat.obj) : error LNK2001: unresolved external symbol _nppiConvert_32f16s_C1R

Here's what I did so far. Compiled OpenCV with:

WITH_CUDA = ON, BUILD_SHARED_LIBS = OFF

I ran opencv_test_gpu and confirmed my OpenCV was built with CUDA support. I also ensure static libs are built instead of dynamic libs, judging from the *.lib file size and simple compilation test. On the VS 2012 side:

Include Directory = C:\opencv_built\install\include, Runtime Library = /MT, Library directory = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\lib\Win32;C:\opencv_built\install\share\OpenCV\3rdparty\lib;C:\opencv_built\install\lib; Additional Dependencies: cudart_static.lib;opencv_calib3d246.lib;opencv_contrib246.lib;opencv_core246.lib;opencv_features2d246.lib;opencv_flann246.lib;libtiff.lib;libpng.lib;libjpeg.lib;libjasper.lib;IlmImf.lib;zlib.lib;opencv_highgui246.lib;opencv_imgproc246.lib;opencv_legacy246.lib;opencv_ml246.lib;opencv_nonfree246.lib;opencv_objdetect246.lib;opencv_photo246.lib;opencv_stitching246.lib;opencv_ts246.lib;opencv_video246.lib;opencv_videostab246.lib;Vfw32.Lib;comctl32.lib;%(AdditionalDependencies).

Can anyone please share some insight where did it went wrong?

Roger Dahl
  • 15,132
  • 8
  • 62
  • 82
user2900552
  • 105
  • 1
  • 3
  • 7
  • Try adding `npp.lib` to your libraries in additional dependencies, like this: `cudart_static.lib;npp.lib;opencv_calib3d246.lib;...` – Robert Crovella Feb 22 '14 at 03:30
  • Hi I just tried that minutes ago, but I tried it with nppc.lib, nppi.lib, npps.lib because I don't have npp.lib in the folder. The solution compiles now, but are those libraries static ones? As I don't have a machine to test now, I am unsure whether will the executable run on another machine without OpenCV/CUDA. – user2900552 Feb 22 '14 at 03:53
  • [Typically in windows](http://stackoverflow.com/questions/140061/when-to-use-dynamic-vs-static-libraries) shared libraries are using the filename extension `.dll` whereas static libraries are using the filename extension `.lib` So, yes, those libraries ending in `.lib` are static. And yes, those libraries (nppc.lib, nppi.lib, npps.lib) are the correct ones to link in. I was looking at an older version of CUDA toolit when I mentioned npp.lib – Robert Crovella Feb 22 '14 at 04:13
  • Hi I just moved the exe to another computer but unfortunately I got an error launching the exe. About nppi32_55.dll is missing – user2900552 Feb 22 '14 at 04:16
  • 1
    @RobertCrovella, typically, `.dll`s are also used via `.lib`s. The `.lib`s are then called import libraries and contain stubs for the functions in the corresponding `.dll`. – Roger Dahl Feb 23 '14 at 23:11
  • Yes, agreed, I wasn't very clear. Any static library in windows is usually ending in `.lib` Any shared library will usually have a `.dll` component somewhere. When a dll gets built, however, both a static (.lib) and dynamic (.dll) component get created. Anyway I think the correct answer in this case is that you cannot create (currently) a fully static version of the npp library. – Robert Crovella Feb 23 '14 at 23:55

1 Answers1

4

I don't believe it's possible (currently, with CUDA 5.5) to build a fully statically-linked application using the npp library. That is because a portion of the library is delivered via a dll component. Read section 15.4 here

In fact, this was not possible at all with CUDA until recently (CUDA 5.5) when a fully statically linkable CUDA runtime library was delivered. So ordinary CUDA applications can be created which don't require additional CUDA dll's to run. However, AFAIK, the libraries (e.g. CUBLAS, CUFFT, CUSPARSE, NPP) all have dll components, and don't offer a fully static version of the library to link against.

EDIT: As newer CUDA versions have been released, some CUDA libraries have incorporated static library/link options. As of CUDA 9.1, the basic CUDA runtime library (libcudart) has a static option (libcudart_static, which is now the default option for nvcc compilation), as do CUFFT (libcufft_static), CUBLAS (libcublas_static), CUSPARSE, CUSOLVER, and NVGRAPH. As of CUDA 9.0/9.1, the NPP libraries have been split into a variety of sub-libraries, but these are all available in static versions as well.

Robert Crovella
  • 143,785
  • 11
  • 213
  • 257