在 2024-09-18 23:04, slipbits 写道:
Win10 x86-64
cygwin v3.5.4

I'm using g++ to link my object modules non-windows object module and g++ includes a windows library. The library seems to need to have a winMain function, which my code does not have, and generates a linker error.

I don't know why there is an automatic need to link to libcmain. Is there any way to remove this library (and why is it there in the first place?).

For Cygwin and mingw-w64, there is a prebuilt `main` function in a default library. The intent is that if a user defines `main` themself, it is called; if they do not define one, the prebuilt one is called, which in turn calls `WinMain` (or `wWinMain` if `-municode` is specified), which then has to be defined by the user.

So the error happened because GCC couldn't find your `main` function and it mistook the prebuilt one. You need to define it in one of your source files.


--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to