Visual Studio: how to create a project that would compile 2 exe files?

后端 未结 6 1887
无人共我
无人共我 2020-12-16 10:20

So I have main.cpp and main2.cpp with int main in each. I want to get 2 exes out of it. Is it possible and what would be instruction to create such project?

6条回答
  •  旧巷少年郎
    2020-12-16 10:56

    I don't know if it can be done ,but the only change you have ,to do this ,is with custom build step.

    EDIT: Since someone downvoted this ,i did a test making a dummy configuration.

    In the custom build step I two Link-cmds (copied form original link-cmdline and modified it a bit) taking as input main1.obj resp. main2.obj and outputting App1.exe resp. App2.exe. It's executed after Compiling and before linking.

    It worked !

    The downside is I cannot prevent (yet) the linking ot the orinal exe (which errors on duplicate main function). Solution to this could be to have a lib project excluding the sources with main()from build and build them in the custum-step too.

    So the answer to the question should : Yes ,it can be done!

提交回复
热议问题