Search code examples
c++gccvisual-c++cl

What is the alternative for cl /NODEFAULTLIB in gcc


I have done a c++ project that doesn't depend on any c/c++ runtime but only windows api I can build it easily with msvc by passing -NODEFAULTLIB to the linker and I end up with a small executable that doesn't depend on any c/c++ runtime I'm thinking now to publish my project and people will be able to build it without msvc (it requires huge disk space) So I decided to go with mingw-w64 and my project will be built also on linux with mingw But I don't want the runtime library to be linked to my application so how can I disable linking to it


Solution

  • -z nodefaultlib seems to do it, see:

    http://rextester.com/SAL68483

    Reference:

    https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options