Compiling FFmpeg with the latest MinGW version doesn't seem to work. I tried with FFmpeg version 2.6.2 and older, MinGW version of the day installed with mingw-get-setup.exe, version 3.21.0 as reported in _mingw.h.
When compiling FFmpeg I get the errors:
[...]
CC libavformat/applehttp.o
In file included from libavformat/applehttp.c:32:0:
c:\mingw\include\unistd.h:79:1: error: expected ',' or ';' before 'int'
int __mingw_sleep( unsigned long, unsigned long );
^
In file included from libavformat/applehttp.c:32:0:
c:\mingw\include\unistd.h:105:1: error: expected ',' or ';' before 'int'
int nanosleep( const struct timespec *, struct timespec * );
^
c:\mingw\include\unistd.h:125:28: error: expected ',' or ';' before 'usleep'
int _cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
^
c:\mingw\include\unistd.h:138:10: error: conflicting types for '_cdecl'
unsigned _cdecl __MINGW_NOTHROW sleep( unsigned );
^
c:\mingw\include\unistd.h:125:5: note: previous declaration of '_cdecl' was here
int _cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
^
c:\mingw\include\unistd.h:138:33: error: expected ',' or ';' before 'sleep'
unsigned _cdecl __MINGW_NOTHROW sleep( unsigned );
^
c:\mingw\include\unistd.h:153:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ftruncate'
int _cdecl ftruncate( int, off_t );
^
make: *** [libavformat/applehttp.o] Error 1
The problem is related to the unistd.h header and to the inclusion of windows.h. Whenever windows.h is included before unistd.h, the compilation fails. Manually adding the include will provide a workaround. Apparently the _cdecl symbol is not defined if windows.h is not included.
See also this link, which provides the workaround:
https://sickrage.tv/forums/forum/help-support/nzbtomedia-support/18113-error-compiling-ffmpeg
I'll try to provide more information if requested.
Thanks for the heads-up! I missed this, when I tested; it's a simple typo in unistd.h
FWIW, the "solution" identified in the link you provided is entirely bogus! The correct solution has nothing to do with windows.h; it is to replace every misuse of
_cdeclin unistd.h with the correctly spelled__cdeclattribute; (note the double leading underscore, as required by ISO-C).I confirm that replacing "_cdecl" with "__cdecl" in the file MINGW_PATH/usr/include/unistd.h will fix the compilation issue.
Thanks.
Thanks. I've committed the obvious changes to the git repository, for inclusion in the next mingwrt release.
Diff: