microsoft / FFmpegInterop

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

Stuck trying to compile FFmpeg (Win10 x64 UWP/WinRT) #67

Closed Shrp77 closed 8 years ago

Shrp77 commented 8 years ago

Hi guys,

I've seen the other threads on this, but haven't been able to figure out what's wrong based on those threads.

I followed the instructions from https://github.com/Microsoft/FFmpegInterop, and I've cloned the FFmpegInterop and FFmpeg repos. I followed the instructions here (https://trac.ffmpeg.org/wiki/CompilationGuide/WinRT) and ensured that I did each step (even though I'm only interested in x64 / UWP, I got the perl script for ARM too).

In the "verifying your FFmpeg Environment Setup" step, I did exactly as stated and the which calls for "cl", "link" and "armasm" failed (the path to the visual studio bin x86_arm folder was not in the msys2 path). "yasm" and "cpp" worked fine, however "gas-preprocessor.pl" could also not be found (even though it's in my msys64\usr\bin folder).

I skipped down to the Compiling for Window 10 x64 block; ran the specified command prompt, set the LIB, LIBPATH and INCLUDE variables and then kicked off Msys2 using the batch file. I then run: export PATH=$PATH:"/D/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64". After this, the "which" command finds "cl" and "link" correctly.

I went to the ffmpeg location, created the output/windows10/x64 folder and ran the configure command, to which msys2 will spit out:

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

I've attached the config.log file. config.txt

BUT: There seems to be some holes in the instructions (I could not - for the life of me - get the which command to give the expected response without doing my own export command call...). Are there any system variables that need to be set or something like that?

Are there any flags that need to be tweaked in order to pass Windows App Certification?

khouzam commented 8 years ago

Hi @Shrp77,

The instructions are fairly finicky because of the required integration between the windows system and the MSYS side.

In order to make things easier, FFmpegInterop includes a script that should enable transparent compilation. Can you go to the root of the repo, and run buildFFmpeg win10 x64 from a plain command prompt. You will have to set the environment to point to your msys2 install such as set MSYS2_BIN=C:\msys64\usr\bin\bash.exe but this should set the right paths for the tools, the libs and everything else.

Judging from your config.log, CL is not able to find the path to the libraries that it needs to link. I don't see where in the instructions the paths have to changed in msys.

Shrp77 commented 8 years ago

Thanks for the reply :)

So I followed your suggestion when I got home from work. It seemed to do something, but then ended in the following message:

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

I've attached the dos output and the new config log file. config.txt

buildFFmpeg-win10-x64.txt

this time it seemed like the build system was unable to find "cl". I'll try modifying the BuildFFmpeg.bat file to set the path to the x86_amd64 build tools folder.

Shrp77 commented 8 years ago

I suspect the problem is that I have my development environment installed on the D drive (since my C drive is a rather small SSD drive).

Checking the vcvarsqueryregistry.bat under the Common7/Tools folder, I see that they're using %ProgramFiles(x86)% and %ProgramFiles% in some of their statements, and those guys are pointing to the C drive.

I'll see if adding a symbolic link from the C:\Program Files to my D location will help...

Shrp77 commented 8 years ago

Ok.

So I added a symlink so that C:\Program Files (x86)\Microsoft Visual Studio 14.0 points to my D:\Program Files (x86)\Microsoft Visual Studio 14.0 installation location.

I ran '"%VS140COMNTOOLS%....\VC\vcvarsall.bat" x64 store' in a blank cmd prompt and then checked the results of "which cl" and "which link" - both of which were located under "/d/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN/amd64"

Followed up with running "BuildFFmpeg.bat win10 x64" and still no joy... Attached the dos output and the console log. buildFFmpeg-win10-x64.txt config.log.txt

Shrp77 commented 8 years ago

BTW: If someone else has their dev environment on another drive than C:, they can use the same tool that I did to make a symlink into the C:\ location...

http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html#download

not that it solved the problem though :...

khouzam commented 8 years ago

Hi Shrp77,

How did you install VS onto the D: Drive? The scripts should be able to handle this, if VS is installed as expected. There are more things than just CL that need to be resolved in order for the environment to work properly. The first one that our scripts use is: %VS140COMNTOOLS% (as well as VS120 but you're targeting Windows 10). You would need to make sure that it points to D: and not C: That environment variable is used to call D:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\vcvarsall.bat which in turns calls more scripts that query the registry for the location of the SDK.

Can you run call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x64 store and then output your environment variables so that we can see if they match what is expected?

Thanks.

Shrp77 commented 8 years ago

Yep - it was a clean install straight to the D: drive.

Here's the output from the call you requested. env.txt

Thanks :)

khouzam commented 8 years ago

Thanks for the details. I'll try it on a new machine and see if I can reproduce the situation,

Shrp77 commented 8 years ago

Awesome - thank you for the support :)

calvin-charles commented 8 years ago

I ran into the same or similar problem and it turned out to be the environment variable issue.

I was able to resolve it by making the below changes: Edit BuildFFmpeg.bat to include the below two lines.

set SET_FULL_PATH=1
set MSYS2_BIN="C:\msys64\usr\bin\bash.exe"

Run the batch file from ‘VS2015 x86 x64 Cross Tools Command Prompt’, so the ‘SET_FULL_PATH=1’ can export full PATH from that environment.

Happy Coding.

Shrp77 commented 8 years ago

That worked perfectly!!

the SET_FULL_PATH seemed to do the trick.

Thank you :)