Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 228
Rella Avatar asked Jan 23 '11 17:01

Rella


People also ask

Can C# be compiled to exe?

After a developer writes the C# code, he or she compiles their code. This results in Common Intermediate Language stored within Portable Executable (PE for 32-bit, PE+ for 64-bit) files such as “.exe” and “. dll” files for Windows. These files are distributed to users.

How do I create a solution file in Visual Studio 2019 for an existing project?

Add files to a solution To add an item to a solution, on the context (right-click) menu of the solution node in Solution Explorer, select Add > New Item, or Add > Existing Item. A solution file is a structure for organizing projects in Visual Studio.


1 Answers

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.

like image 147
jalf Avatar answered Oct 06 '22 00:10

jalf