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

后端 未结 6 1884
无人共我
无人共我 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 11:03

    Nope, Visual Studio's project model is rigidly built around the assumption that "one project generates one output".

    If you need two executables, you have to create two projects. You can keep them in the same solution to make things easier for yourself, but they have to be separate projects.

    Edit
    Ok, as other answers have pointed out, it can of course be done, if you're desperate. You can add a custom build step, which does anything you like, including building another executable. (However, the build system won't understand that this file should be considered project output, and so some scenarios may fail: for example the file won't be automatically copied to the output folder, and when checking dependencies before a rebuild, it might not be able to understand which files to check, and what (or how) to rebuild.)

    Visual Studio (at least up to 2008, not sure about 2010) also allows the use of nmake files, but then I think you're stretching the definition of "a Visual Studio project".

    But under "normal" circumstances, one project implies one output. And in order to get two executables, you'd normally create two projects.

提交回复
热议问题