Reputation: 123
I have 3 static libraries, one of them (BinaryMain) has the entry function
int32_t main(int32_t arg, char** argv) { .. .. }
I want to create an executable by combining these three static libraries (BinaryMain, Binary1, Binary2)
While creating static binary (Binary1 and Binary 2) i want to use specific linker script file (binary1.ld, binary2.ld) and also generate map files for each of them. BinaryMain had reference to variables/functions in Binary1 and Binary2 which i suppressed using
attribute((weak))
.
But while creating static library (Binary1 and Binary2) i get the error
(.text.startup+0x25): undefined reference to `WinMain'
the command line for each static binay used is
g++ -o libbinary1.a -Wl,--start-group component1.a component2.a -static -Xlinker -Map=binary1.map -Tbinary1.ld -Wl,--end-group -LTools\win-builds-64\lib -LTools\msys_Python\Python34 -lstdc++ -lgcov -lpython34
i know main entry is only in libBinaryMain.a and is not contained in libbinary1.a or libbinary2.a but how do i tell the linker to stop looking for 'WinMain' when linking these two binaries.
I have an equivalent target build, where all the three binaries are elf, one containing the main. I am not sure wether my attempt to create a pc build would work with an exe.
Awaiting some valuable suggestion. Thanks in Advance Sid
Upvotes: 3
Views: 751
Reputation: 48019
The linker thinks you're building a GUI application rather than a console application, so it's looking to resolve the entry point WinMain
instead of main
. You can use -mconsole
to tell the linker you want a console application.
Upvotes: 1