undefined reference to `WinMain' : When using Cygwin, SDL2 and Netbeans

前端 未结 2 1577
一生所求
一生所求 2021-01-22 05:32

any help here would be appreciated. Ive really racked my brains at this, sooo.

I have installed cygwin, and Netbeans and have been successfully deving, compiling and run

相关标签:
2条回答
  • 2021-01-22 05:58

    For a library that I just built with Cygwin, I added the following compiler flags:

     -shared -Wl,--out-implib,lib$(LIB_NAME).dll.a
    

    This allowed me to build my library without the dreaded, "missing WinMain," error message.

    0 讨论(0)
  • Have you tested with an #undef main infront of your main?

    /*
     * If 'main' is defined we clear that definition
     * to get our default 'main' function back.
     */
    #ifdef main
    # undef main
    #endif /* main */
    
    int main(int argc, char** argv)
    {
        // ...
        return 0;
    }
    

    Using Netbeans with Cygwin and SDL, including SDL.h creates strange error


    May also help:

    I get "Undefined reference to 'WinMain@16'"

    Under Visual C++, you need to link with SDL2main.lib. Under the gcc build environments including Dev-C++, you need to link with the output of "sdl-config --libs", which is usually: -lmingw32 -lSDL2main -lSDL2 -mwindows

    ( http://wiki.libsdl.org/FAQWindows#I_get_.22Undefined_reference_to_.27WinMain.4016.27.22 )

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