Problem compiling ffmpeg with nvenc using visual studio 2015 community edition

I’m trying to build ffmpeg w/ nvenc on Windows 10 64 bit and visual studio 2015 community edition. The command from step 10 in the Using FFmpeg with NVIDIA GPU Hardware Acceleration doc:

./configure --enable-nonfree --enable-cuda-sdk --enable-libnpp –-toolchain=msvc --extra-cflags=-I…/nv_sdk --extraldflags=-libpath:…/nv_sdk

Gives me the error ‘Unknown option “–-toolchain=msvc”’

Background: I’ve executed the commands (changed the path in the first, I’m not sure its right):

export PATH="/C/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/":$PATH export PATH="/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/bin/":$PATH

And …/nv_sdk has the subdirectories include & bin, copied from the NVIDIA GPU Computing Toolkit directory.

1 Like

Did you solve this? I am facing this problem too.

First write the command ./configure --toolchain=msvc. After configuration has finished, run the configuration again like this: ./configure -toolchain=msvc --enable-cuda-nvcc --enable-nonfree --enable-libnpp --extra-cflags=-I…/nv_sdk --extraldflags=-libpath:…/nv_sdk. Do not use –enable-cuda-sdk, it has been deprecated. There will be error again. Modify the configure file in the main directory. Search for the word gencode in the file. You will see a line like this: nvccflags_default="-gencode arch=compute_30,code=sm_30 -O2". Replace 30 by converting your gpu’s compute capability version. FOR EXAMPLE: if your gpu has compute capability 6.1 then replace 30 with 61.

1 Like

Thank you for sharing the solution and I’d like to mention that there are some typos in the command.
In the second command:
-toolchain=msvc
should be

--toolchain=msvc

I do NOT think you need to run the following first if the typo in the second command is fixed:
./configure --toolchain=msvc

And this forum editor may changed
DotDot
to some weird … unicode character, be careful when you copy them. (The ones next to libpath and extra-cflags

The command works for me:
./configure --enable-cuda-nvcc --disable-shared --enable-nonfree --enable-libnpp --toolchain=msvc --extra-cflags=-I…/nv_sdk --extra-ldflags=-libpath:…/nv_sdk

The gencode comment really helped me a lot. I changed it to 61 as I’m using GTX 1080 and its compute capability is 6.1
and you can find yours here: https://developer.nvidia.com/cuda-gpus

In my case, I proceeded as follows. I’m using visual studio 2019.
Please comment if you know how to fix it.


msys2_shell.cmd -mingw64

export PATH="/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/":$PATH
export PATH="/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2/bin/":$PATH

$ which cl
/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl

cd nv-codec-header make install PREFIX=/usr

cd.. cd ffmpeg

$ ./configure --enable-cuda-sdk --disable-shared --enable-nonfree --enable-libnpp --toolchain=msvc --extra-cflags=-I…/nv_sdk --extra-ldflags=-libpath:…/nv_sdk

The cl.exe error occurs as shown below.

cl.exe is unable to create an executable file.
If cl.exe is a cross-compiler, use the --enable-cross-compile option.
Only do this if you know what cross compiling means.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file “ffbuild/config.log” produced by configure as this will help
solve the problem.

My Error Log as shown below.

test_ld cc
test_cc
BEGIN ./ffconf.fLNB2Hzt/test.c
1 int main(void){ return 0; }
END ./ffconf.fLNB2Hzt/test.c
cl.exe -nologo -I…/nv_sdk -c -Fo./ffconf.fLNB2Hzt/test.o ./ffconf.fLNB2Hzt/test.c
test.c
./compat/windows/mslink -libpath:…/nv_sdk -nologo -out:./ffconf.fLNB2Hzt/test.exe ./ffconf.fLNB2Hzt/test.o
LINK : error LNK2001: mainCRTStartup 외부 기호를 확인할 수 없습니다.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\lib\x86\LIBCMT.lib : warning LNK4272: ‘X86’ 라이브러리 컴퓨터 종류가 ‘x64’ 대상 컴퓨터 종류와 충돌합니다.
./ffconf.fLNB2Hzt/test.exe : fatal error LNK1120: 1개의 확인할 수 없는 외부 참조입니다.
C compiler test failed.

Hello,
I’m also trying today to compile with Visual Studio 2019 and every time I have the following error:

MINGW64 ~/ffmpeg
$ ./configure --toolchain=msvc
cl.exe is unable to create an executable file.
If cl.exe is a cross-compiler, use the --enable-cross-compile option.
Only do this if you know what cross compiling means.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file “ffbuild/config.log” produced by configure as this will help
solve the problem.

Please help.

I did everything else recommended by xywhpanda, even changed the gencode, but always getting the same error

from the log I see this:
WARNING: Unknown C compiler cl.exe, unable to select optimal CFLAGS
test_ld cc
test_cc
BEGIN ./ffconf.A0M5rfxR/test.c
1 int main(void){ return 0; }
END ./ffconf.A0M5rfxR/test.c
cl.exe -c -o ./ffconf.A0M5rfxR/test.o ./ffconf.A0M5rfxR/test.c
./configure: line 983: cl.exe: command not found
C compiler test failed.

Hello,
I am getting the same error and have not found any solution online. Have you found one?

–-toolchain=msvc wrong spell before toolchain