ffmpeg ERROR: libnpp not found in windows

If you check config.log, there may have a lot link warnings:
LINK : warning LNK4044: unrecognized option '/L...'; ignored
cause
ERROR: libnpp not found.
Since /L is not a correct argument for msvc linker, in order to include library path, the argument should as follow:
./configure .... --extra-cflags=-I/usr/local/cuda/... --extra-ldflags=-LIBPATH:/usr/local/cuda/...
This should able to solve the libnpp not found issue. FYI, linker options are listed in the following link (included LIBPATH): Linker Options


Actually I went nuts about ffmpeg is not building with the same problem. I fianally managed to get it worked under Windows 10 x64:

  1. Download msys2 from https://www.msys2.org/ and install all packages with Pacman

  2. pacman -Su

  3. pacman -S make

  4. pacman -S diffutils

  5. pacman -S yasm

  6. pacman -S mingw-w64-x86_64-gcc

  7. pacman -S mingw-w64-x86_64-toolchain

  8. add pkgconfig to environment variable PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

  9. Add additional installed toolchain to path: PATH=$PATH:/opt/bin

  10. Start mingw64 version: C:\msys64\msys2_shell.cmd -mingw64

  11. Download and install Cuda from nVidia https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exenetwork

  12. Extract the downloaded file e.g. cuda_11.2.2_461.33_win10.exe with 7zip locally

  13. Copy cuda_nvcc\nvcc\include to your msys2 e.g. C:\msys64\tmp\nvidia_include

  14. Copy libnpp\npp_dev\lib\x64 to your C:\msys64\tmp\nvidia_lib\x64

  15. Copy libnpp\npp_dev\include to C:\msys64\tmp\nvidia_npp_include

  16. git clone https://github.com/FFmpeg/FFmpeg.git to C:\msys64\home\<user>

  17. git clone https://github.com/libav/libav to C:\msys64\home\<user>

  18. Maybe optional step: git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git to C:\msys64\home\<user>

  19. make

  20. make install

  21. Optional because make install should have done this for you: Copy ffnvcodec.pc to C:\msys64\usr\local\lib\pkgconfig

  22. Build libav avconv.exe and avprobe.exe are needed for ffmpeg later:

  23. cd C:\msys64\home\<user>\libav

  24. ./configure

  25. make

  26. make install

  27. Finally build ffmpeg:

  28. cd C:\msys64\home\<user>\ffmpeg

  29. ./configure --enable-nonfree --disable-shared --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags=-I/tmp/nvidia_npp_include --extra-cflags=-I/tmp/nvidia_include --extra-ldflags=-L/tmp/nvidia_lib/x64

  30. make

  31. make install

  32. Copy avconv.exe and avprobe.exe to ffmpeg directory

Done.

Bugfixing:

  • Missing DLLs: find x64 missing DLLs on your harddisk or in internet.
  • Use dependency walker for analyzing errors
  • Download the newest nVidia drivers and use nSight making sure CUVID is supported for your graphic card.

I managed to successfuly cross compile ffmpeg under linux targeting Windows 64 bit with --enable-libnpp included.

My environment is Ubuntu Server 16.10 64bit.
After a fresh installation I installed MinGW using the command:

sudo apt-get install mingw-w64

First I successfully compiled the Linux version with the --enable-libnpp option activated following the instructions on the NVIDIA dev site Compile Ffmpeg with NVIDIA Video Codec SDK.
In order to do that you need to install the CUDA Toolkit. Just follow the instructions and the package installer will create the symbolic links (I have the CUDA Toolkit 8.0):

/usr/local/cuda/include/ -> /usr/local/cuda-8.0/targets/x86_64-linux/include
/usr/local/cuda/lib64/ -> /usr/local/cuda-8.0/targets/x86_64-linux/lib

This should provide Configure the right path to find the correct libraries and headers.
The command line I have used to compile the linux version of ffmpeg is:

./configure --enable-nonfree --disable-shared --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags=-I/usr/local/cuda/include/ --extra-ldflags=-L/usr/local/cuda/lib64/

The problem you got is that when using cross-compilation you need to provide Configure the right path where to find headers and library for the Windows version of the libnpp library.
From the CUDA Toolkit Download page mentioned above I simply downloaded the exe(local) version of the Windows package.
Under the root of my working folder I created a folder called tmp where I copied the subfolders I found under npp_dev inside the package cuda_8.0.61_win10.exe:

cuda_8.0.61_win10.exe\npp_dev\lib -> tmp/lib  
cuda_8.0.61_win10.exe\npp_dev\include -> tmp/include

As final step I launched Configure once again using the following parameters:

./configure --arch=x86_64 --target-os=mingw32 --cross-prefix=x86_64-w64-mingw32- --pkg-config=pkg-config --enable-nonfree --disable-shared --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags=-I/usr/local/include --extra-cflags=-I/usr/local/cuda/include/ --extra-ldflags=-L/usr/local/cuda/lib64/ --extra-cflags=-I../tmp/include/ --extra-ldflags=-L../tmp/lib/x64/

The compilation completed successully. When I copied the ffmpeg.exe file to Windows and tried to execute it I got an errore message saying the executable was missing some npp_*.dll.
From the package cuda_8.0.61_win10.exe I copied all the dlls included into the folder npp\bin to the same directory I put ffmpeg.exe.
After that the application run normally and a simple conversion from a 4K file completed as expected.


This would seem to be caused by a broken configuration script in the FFmpeg code base. There is no library called npp in recent CUDA distributions, instead on Windows platforms you will have

nppc.lib
nppi.lib
npps.lib

and on linux

libnppc.so
libnppi.so
libnpps.so

You will either need to modify the configuration system yourself or file a bug request with the project developers to do it for you.

There might still be additional problems building the project with MinGW, but that is way beyond the scope of a Stack Overflow question.