Menu

#2256 Compilation issues with latest MinGW and FFmpeg

OTHER
closed
Bug
fixed
IINR_-_Include_In_Next_Release
False
2015-05-08
2015-05-06
No

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.

Related

Issues: #2251

Discussion

  • Keith Marshall

    Keith Marshall - 2015-05-07

    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 _cdecl in unistd.h with the correctly spelled __cdecl attribute; (note the double leading underscore, as required by ISO-C).

     
    • Stefano Sabatini

      I confirm that replacing "_cdecl" with "__cdecl" in the file MINGW_PATH/usr/include/unistd.h will fix the compilation issue.

      Thanks.

       
      • Keith Marshall

        Keith Marshall - 2015-05-08

        Thanks. I've committed the obvious changes to the git repository, for inclusion in the next mingwrt release.

         
  • Keith Marshall

    Keith Marshall - 2015-05-07
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,6 +1,8 @@
     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:
    @@ -28,6 +30,7 @@
      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.
    
    • status: unread --> assigned
    • assigned_to: Keith Marshall
     
  • Keith Marshall

    Keith Marshall - 2015-05-08
    • status: assigned --> closed
    • Resolution: none --> fixed
    • Category: Unknown --> IINR_-_Include_In_Next_Release
     
Monday.com Logo