I am trying to build a server with no Qt classes using qmake (since it creates Makefiles so well) with MinGW mixed in there.
I am able to build GUIs fine, but this server fails with:
There are thousands of posts on the web about this error, and I think I've tried all the fixes:[...]libmingw32.a(main.o):main.c.text+0x104): undefined reference to 'WinMain@16'.
- Changed int main() to void main()
- Since this is a server with no GUI, I added CONFIG += console (same error with or without console)
- Added "QT -= gui" to .pro file
- Added "LIBS += -lmingw32 -mwindows" to .pro file
- Added "QT_CXXFLAGS+=-mwindows" to .pro file
- Added "CXXFLAGS += -mwindows"
- Added "LIBS += -u _WinMain@16" to .pro file
- Reversed library order (I get the same error but from a cygwin library)
- Added explicity path to libmingw32.a (although I think it found it)
- Added "using namespace std" in the file with my main()
- Added these two lines: "int WinMain@16();" and "intWinMain@16() { }"
- Added these two lines: "int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmd, int show);" and "int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmd, int show) { return 0; }"
- Removed all main() functions
- Added "LIBS += -lmingw32 -mwindows"
- Added "LIBS += -lgdi32 -lkernel32 -luser32 -lshell32 -lm"
- Moved mingw32 libraries to beginning of LIBS
None of these solutions remove the "undefined reference to 'WinMain@16'" error.
Have I left anything off?
Bookmarks