Fix linking the outputs of the compilation #76
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this change, running link.exe on the output of the compilation produced
LINK : fatal error LNK1561: entry point must be defined.This took longer to figure out than I would be willing to admit.
There are two things at play - linker uses the presence of a method named
mainorwmainto choose between settingwmainCRTStartupormainCRTStartupas the actual entrypoint of the application (C apps don't start withmain- they start in the C runtime library that callsmain).In #21 we deleted the
__fail_fastmethod from main.cpp and then in #72 we also removed the compiler reference to the now non-existent symbol. The obscure result of that was that main.obj stopped being part of the linking set because nothing now references symbols from it. When linker looks formainorwmain, it only looks at object files that are already part of the linking set.As a result, linker didn't inject
wmainCRTStartupas the entrypoint and we failed with the above message.It looks like the only way out is to hardcode the CRT implementation detail here. We were already hardcoding it, but for other reasons.
We also need to set the subsystem since the autodetection is failing.