EDN Admin
Well-known member
Hello all
Does anybody know how to set the output file (*.exe) name from with within the source code? I have an application that I would like to compile into two different executables. It is basically a client/server application, built with VC++.net Express edition, and the code for the client and server are so similar that I am using a single project and a #define statement to switch between the client and server outputs. And yes, they do need to be different executables.
I have attempted to do this by setting the (/OUT:[file]) linker option as shown below. I get a LNK4070 error when attempting to compile this and get the message "EXP differs from output filename".
<div style="text-align:left
<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100% Code Block
#define CLIENT
#if defined( CLIENT )
#pragma comment(linker, "/OUT:"C:\Projects\MyProject\Client.exe"")
#elif defined( SERVER )
#pragma comment(linker, "/OUT:"C:\Projects\MyProject\Server.exe"")
#endif
The documentation for the /OUT linker option says that it should overwrite the output file name set in the project properties but this doesnt seem to be the case. Basically I would like to give the linker a pre-processor message to set the output executable file name.
Or perhaps I am taking the wrong approach here. Does anybody knwo if there is a .NET method of changing the output executable name from within the code? If you know how this is achvieved in C# or VB.net please let me know and I will convert it to VC++.net.
Daniel
View the full article
Does anybody know how to set the output file (*.exe) name from with within the source code? I have an application that I would like to compile into two different executables. It is basically a client/server application, built with VC++.net Express edition, and the code for the client and server are so similar that I am using a single project and a #define statement to switch between the client and server outputs. And yes, they do need to be different executables.
I have attempted to do this by setting the (/OUT:[file]) linker option as shown below. I get a LNK4070 error when attempting to compile this and get the message "EXP differs from output filename".
<div style="text-align:left
<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100% Code Block
#define CLIENT
#if defined( CLIENT )
#pragma comment(linker, "/OUT:"C:\Projects\MyProject\Client.exe"")
#elif defined( SERVER )
#pragma comment(linker, "/OUT:"C:\Projects\MyProject\Server.exe"")
#endif
The documentation for the /OUT linker option says that it should overwrite the output file name set in the project properties but this doesnt seem to be the case. Basically I would like to give the linker a pre-processor message to set the output executable file name.
Or perhaps I am taking the wrong approach here. Does anybody knwo if there is a .NET method of changing the output executable name from within the code? If you know how this is achvieved in C# or VB.net please let me know and I will convert it to VC++.net.
Daniel
View the full article