microsoft / FFmpegInterop

This is a code sample to make it easier to use FFmpeg in Windows applications.
Apache License 2.0
1.31k stars 313 forks source link

cl is unable to create an executable file. #60

Open coral opened 8 years ago

coral commented 8 years ago

Followed the guide

Configure throws:

cl is unable to create an executable file. C compiler test failed.

$ which link
/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN/x86_amd64/link

$ which cl
/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN/x86_amd64/cl

$ echo $PATH
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft/TestWindow:/c/Program Files (x86)/MSBuild/14.0/bin:/c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE:/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN/x86_amd64:/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN:/c/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/Tools:/c/WINDOWS/Microsoft.NET/Framework/v4.0.30319:/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/VCPackages:/c/Program Files (x86)/HTML Help Workshop:/c/Program Files (x86)/Microsoft Visual Studio 14.0/Team Tools/Performance Tools:/c/Program Files (x86)/Windows Kits/8.1/bin/x86:/c/Program Files (x86)/Microsoft SDKs/Windows/v10.0A/bin/NETFX 4.6 Tools:/c/ProgramData/Oracle/Java/javapath:/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files (x86)/QuickTime/QTSystem:/c/Program Files (x86)/Livestreamer:/c/Program Files (x86)/Windows Kits/8.1/Windows Performance Toolkit:/c/Program Files (x86)/GtkSharp/2.12/bin:/c/Program Files/nodejs:/c/Program Files (x86)/Skype/Phone:/c/Program Files/OpenVPN/bin:/c/Program Files/Common Files/Autodesk Shared:/c/Program Files (x86)/Autodesk/Backburner:/c/Users/coral/AppData/Local/Programs/Python/Python35/Scripts:/c/Users/coral/AppData/Local/Programs/Python/Python35/ :/c/ffmpeg/bin:/c/Users/coral/AppData/Roaming/npm:/c/Users/coral/AppData/Local/Programs/Git/cmd:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
khouzam commented 8 years ago

Can you look at the configure log to see what might be failing?

khouzam commented 8 years ago

Hi @coral

Can you try again with the latest code? We had an older version of MSYS and some recent updates have changed how the environment is passed from Windows to MSYS. We think we've addressed the issue in the latest buildFFmpeg script.

Thanks.

arn0dre commented 8 years ago

Hi there! I guess I'm facing the same problem. I just downloaded the latest code. Here are the last couple of lines from my config.log:

. . zoompan_filter=yes zoompan_filter_deps=swscale WARNING: pkg-config not found, library detection may fail. mktemp -u XXXXXX z83Vms check_ld cc check_cc BEGIN ./ffconf.qtofmUve.c 1 int main(void){ return 0; } END ./ffconf.qtofmUve.c cl -nologo -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64 -MD -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WIN32_WINNT=0x0A00 -c -Fo./ffconf.BK8mpYDh.o ./ffconf.qtofmUve.c ffconf.qtofmUve.c link -APPCONTAINER WindowsApp.lib -o ./ffconf.9uGzz4YC.exe ./ffconf.BK8mpYDh.o link: unknown option -- A Try 'link --help' for more information. C compiler test failed.

any ideas?

arn0dre commented 8 years ago

I installed pkg-config with pacman -S pkg-config, but still I'm unable to build.

config.log

zoompan_filter_deps=swscale
mktemp -u XXXXXX
PSKP72
check_ld cc
check_cc
BEGIN ./ffconf.8gJjbbTD.c
    1   int main(void){ return 0; }
END ./ffconf.8gJjbbTD.c
cl -nologo -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64 -MD -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WIN32_WINNT=0x0A00 -c -Fo./ffconf.RhmeOMsT.o ./ffconf.8gJjbbTD.c
ffconf.8gJjbbTD.c
link -APPCONTAINER WindowsApp.lib -o ./ffconf.1PVtJIuY.exe ./ffconf.RhmeOMsT.o
link: unknown option -- A
Try 'link --help' for more information.
C compiler test failed.
$ which cl
/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN/amd64_x86/cl

$ which link
/usr/bin/link

$ which armasm
/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_arm/armasm

$ which yasm
/usr/bin/yasm

$ which cpp
/usr/bin/cpp

in BuildFFmpeg.bat I also set the MSYS2_PATH_TYPE=inherit

@setlocal
@echo off

if "%1" == "/?" goto Usage
if "%~1" == "" goto Usage

:: Initialize build configuration
set BUILD.ARM=N
set BUILD.x86=N
set BUILD.x64=N
set BUILD.win10=N
set BUILD.win8.1=N
set BUILD.phone8.1=N
set MSYS2_PATH_TYPE=inherit

Visual Studio Community 2015, Win 10

arn0dre commented 8 years ago

It looks like I could build successfully. I switched from branch master to origin/ffmpeg3.0.1 (d81eacbdca7c19a03ff5626bf26fdb7cf20f77a4)

khouzam commented 8 years ago

Hi @arn0dre

It looks like link in your path is the one from MSYS and not from Visual Studio. From the instructions on https://trac.ffmpeg.org/wiki/CompilationGuide/WinRT You might have missed this following step: Rename or remove link.exe in the MSYS2 usr bin folder (E.g. C:\msys64\usr\bin\link.exe) to prevent conflict with MSVC link.exe

DaweiX commented 7 years ago

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

$ which link /c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_arm/link

$ which armasm /c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_arm/armasm

$ which yasm /usr/bin/yasm

$ which cpp /usr/bin/cpp

...but I meet the same problem"cl is unable to create an executable file.C compiler test failed.“

DaweiX commented 7 years ago

And these are the last several lines of the file "config.log":

WARNING: Unknown C compiler cl, unable to select optimal CFLAGS check_ld cc check_cc BEGIN ./ffconf.8v8wIhCG.c 1 int main(void){ return 0; } END ./ffconf.8v8wIhCG.c cl -MD -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WIN32_WINNT=0x0A00 -D__ARM_PCS_VFP -march=armv7 -c -o ./ffconf.XHNTZqQU.o ./ffconf.8v8wIhCG.c ../../../configure: line 872: cl: command not found C compiler test failed.

khouzam commented 7 years ago

Hi @DaweiX,

Can you open FFmpegConfig.sh and copy the command-line to build FFmpeg and see if that works? If cl is not found that's usually a sign that the path is not properly passed to MSys2.

DaweiX commented 7 years ago

From https://trac.ffmpeg.org/wiki/CompilationGuide/MSVC Note: You might see an error saying cl can't generate executable; this is because you installed the link.exe from MSYS. It conflicts with the link.exe of Visual Studio. This can also indicate that you are mixing 64bit and 32bit versions of cl.exe and link.exe. So what should I do with a x64 machine? I tried "export PATH="/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN/amd64_arm/":$PATH" instead of “export PATH=$PATH:"/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_arm"” and then used "which" to see if cl and link can be found. But msys2 still says " cl is unable to create an executable file."

rainabba commented 7 years ago

I'm also hitting the "cl is unable to create...." error. In WSL bash, which cl returns nothing, but then I wouldn't expect it to since I've done nothing to add it to the path and I'd expect it to be a win32 exe that wouldn't run in WSL. What have I missed and/or assumed incorrectly? Thanks in advance.

Also, it doesn't appear that pushd and popd are supported in my WSL bash environment. Is that something I'm missing, or something enabled via the scripts running and so wouldn't appear available in a terminal?

khouzam commented 7 years ago

@DaweiX,

There are a many reasons why this fails and a lot of hints are in the log. "cl is unable to create an executable" is usually the message but looking at config.log helps identify the root cause.

In your scenario. it looks like this is the cause: ../../../configure: line 872: cl: command not found So that usually means that cl is not in the path.

Can you detail the steps that you're taking to build. Are you setting up your environment and then calling configure? What parameters are you passing to configure? Can you attach your complete config.log as it has some valuable information (such as the PATH used within the script).

@rainabba.

For the WSL interop, unlike with MSys, the full filename needs to be included, so if you want to check if cl is in your path, you need to do which cl.exe with the extension. pushd and popd should be fully supported in WSL. What build of Windows are you running?

lukiyori commented 7 years ago

Hello I am having a similiar problem,

I've uploaded my log to: http://www.filedropper.com/config_131

rainabba commented 7 years ago

@khouzam Thank you. I suspect my issue is as mentioned at https://github.com/Microsoft/FFmpegInterop/issues/102 .I realized that I'm on 14393. Thinking about taking the dive on my main workstation to use an insider build. In the meantime, I'm going to revisit all of this on another machine with a newer build and see if I can get past it there. In that other issue, someone also mentioned updating Ubuntu (I assume they mean the WSL environment) to 16.x so I'll keep an eye on that also.

khouzam commented 7 years ago

Hi @lukiyori

It looks like your install of Visual Studio seems to be slightly broken. Can you build a simple C++ project from Visual Studio? Can you try to repair your Visual Studio install?

lukiyori commented 7 years ago

Hi @khouzam ,

The problem was not related with the Visual Studio, I build by following the steps from scratch finally I could be able to build by using the BuildFFmpeg.bat. Thank you very much.

khouzam commented 7 years ago

@lukiyori,

Great, glad to hear its working.

duhyun commented 5 years ago

in Developer Command Prompt try this msys2_shell.cmd -use-full-path

mercuito commented 5 years ago

I ran into this problem recently and found this issue at the top of Google, so I figured I'd drop this here for any future pioneers building FFMPEG in this manner, following this guide

https://trac.ffmpeg.org/wiki/CompilationGuide/WinRT

The problem with that guide is when it tells you to set some environment variables in the command prompt before launching the MSYS2 shell, to build the actual code (ffmpeg). Specifically This. Friggin. Step.

SET LIB=%VSINSTALLDIR%VC\lib\store\amd64;%VSINSTALLDIR%VC\atlmfc\lib\amd64;%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64;;%UniversalCRTSdkDir%lib\%UCRTVersion%\um\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\x64;;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Lib\um\x64
SET LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib\amd64;%VSINSTALLDIR%VC\lib\amd64;
SET INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%UniversalCRTSdkDir%Include\%UCRTVersion%\ucrt;%UniversalCRTSdkDir%Include\%UCRTVersion%\um;%UniversalCRTSdkDir%Include\%UCRTVersion%\shared;%UniversalCRTSdkDir%Include\%UCRTVersion%\winrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Include\um;

First of all, those paths may not even resolve to anything so double check. in my case %VSINSTALLDIR% wasn't even defined. These paths also vary depending on which version of VS you have, and which version of the build tools. For example:

%VSINSTALLDIR%VC\lib\store\amd64

was flat out wrong. I had to change it to

%VSINSTALLDIR%VC\Tools\MSVC\14.22.27905\lib\x64\store

to actually point it to the right place

Anyways, root cause is likely this: it can't compile because it can't find the dang libs or headers, cause the Include And Lib paths are likely borked, so double check those paths before building anything. Daggum

meJevin commented 3 years ago

Was this issue really not solved? Same problem:

WARNING: Unknown C compiler cl.exe, unable to select optimal CFLAGS test_ld cc test_cc BEGIN ./ffconf.kDMpVa6Q/test.c 1 int main(void){ return 0; } END ./ffconf.kDMpVa6Q/test.c cl.exe -DCONFIG_SAFE_BITSTREAM_READER=1 -c -o ./ffconf.kDMpVa6Q/test.o ./ffconf.kDMpVa6Q/test.c ./configure: line 974: cl.exe: command not found C compiler test failed.

vadosnaprimer commented 2 years ago

in Developer Command Prompt try this msys2_shell.cmd -use-full-path

I'm getting the same problems in a different project while building libav on Windows, but running this command from msys2 root folder solved the cl problem for me!

Beyllin commented 2 years ago

I am trying to install nv-codec-headers, I follow the steps shown here: Steps I follow

Steps:

  1. Open Shell Vision Studio 2019 -> Developer Command Prompt for VS 2019

  2. C:/msys64/mingw64.exe

  3. export PATH="/C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/HostX64/x64/":$PATH export PATH="/C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/bin/":$PATH

  4. cd C:/nv-codec-headers

  5. make install PREFIX=/usr

  6. cd C:/ffmpeg

  7. -> ./configure --enable-nonfree --disable-shared --enable-cuda-nvcc --enable-libnpp –-toolchain=msvc --extra-cflags=-I../nv_sdk --extra-ldflags=-libpath:../nv_sdk

Then when I get here, I get this error: "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.libera.chat. Include the log file "ffbuild/config.log" produced by configure as this will help solve the problem."

See this screenshot

I have attached the completed config log Config Log

Please help me. I really want to fix this issue. Thank you for your help.

pourjour commented 1 year ago

I had the same problem while trying to build ffmpeg for msvc x64 instead of x86 so I chnaged cl and link to x64 but still had a problem then I checked config.log in ffbuild folder I noticed it's linking against x86 libs so I changed environment variables "LIB" and "LIBPATH" to x64 libs and that fixed the problem for me. PS: I'm posting for anyone facing the same issue.

tidys commented 1 year ago

Set operating system environment variables

MSYS2_PATH_TYPE=inherit

I solved it successfully