Can you statically compile a cygwin application?

后端 未结 3 1235
谎友^
谎友^ 2020-12-09 03:50

Does cygwin allow a statically compiled binary? This would prevent the need for cygwin1.dll being on the PATH of target machines.

相关标签:
3条回答
  • 2020-12-09 03:57

    For Cygwin with mingw32 installed, your command line would be of the form

    x86_64-w64-mingw32-gcc.exe main.c -o main.exe
    

    This bypasses the need for cygwin1.dll altogether.

    0 讨论(0)
  • 2020-12-09 04:14

    Cygwin's GCC no longer supports -mno-cygwin.

    Try to use mingw-gcc instead, e.g. x86_64-w64-mingw32-gcc, as mentioned in the Cygwin FAQ.

    0 讨论(0)
  • 2020-12-09 04:16

    Nope, it's currently not possible to statically link against cygwin1.dll; if your application does not use unix emulation (i.e. pure win32) you can pass -mno-cygwin to the compiler.

    See also the FAQ:
    http://cygwin.com/faq/faq.html#faq.programming.win32-no-cygwin
    http://cygwin.com/faq/faq.html#faq.programming.static-linking

    0 讨论(0)
提交回复
热议问题