-
May 9th, 2009, 01:58 AM
#1
How-to specify the name of compiled output (*.exe) within C++ code?
Hello
How can I specify the name of the compiled output (the .exe) within my C++ code?
I'm using Visual Studio 2008.
Please tell me if this is possible, and if it is, how to do so.
Thanks in advance,
Panarchy
-
May 9th, 2009, 09:20 AM
#2
Re: How-to specify the name of compiled output (*.exe) within C++ code?
within your c++ code ? What do you mean by that ?
-
May 9th, 2009, 09:32 AM
#3
Re: How-to specify the name of compiled output (*.exe) within C++ code?
You can't specify the name of the exe with your code. That's in the build options of the IDE.
-
May 9th, 2009, 09:55 AM
#4
Re: How-to specify the name of compiled output (*.exe) within C++ code?
Don't you think your question is a sort of chicken and egg problem.
To get the output name you have to build and run the EXE.
To build the EXE you have to give it a name.
If you mean you want to show the name of EXE from within the code you can either use the argv[0] parameter in the case of console application or in the case of Windows applications you can use GetCommandLine and CommandLineToArgvW functions.
Last edited by _Superman_; May 9th, 2009 at 10:02 AM.
-
May 10th, 2009, 09:43 PM
#5
Re: How-to specify the name of compiled output (*.exe) within C++ code?
I was just thinking, I could have 1 command prompt window open, and 1 Visual Studio main.cpp (or equivalent) open.
I could then make the changes to the code, Alt-Tab to the command-prompt window, then put in what I want the .exe to be via the /out parameter.
Advantages;
- No extra code needs to be added
- So the size of my program won't enlarge
Problem solved!
Disadvantages;
- Have to do an Alt-Tab
- Command-Prompt sucks, as I need to right-click, Paste
Though I still would like to know if this can be done programmatically, it is no longer a priority.
If you know how I can get this to be done programmatically, please tell me.
Thanks in advance,
Panarchy
Links:
/OUT
Output File
-
May 10th, 2009, 10:11 PM
#6
Re: How-to specify the name of compiled output (*.exe) within C++ code?
You could probably write/record a macro that takes as input the name of the output desired. The could be put as a button on the toolbar.
On running the macro, it could set the output name in the Output File option in Project Properties -> Configuration Properties -> Linker.
-
May 11th, 2009, 06:56 PM
#7
Re: How-to specify the name of compiled output (*.exe) within C++ code?
Thanks, but the /out parameter can do it, if I can just work out how to use it.
Any ideas?
Panarchy
-
May 11th, 2009, 09:15 PM
#8
Re: How-to specify the name of compiled output (*.exe) within C++ code?
Hi
I've worked it out, first I need to do a;
cl /clr "test.cpp"
Then
Link "Test.obj" /out:"testing.exe"
There is one problem with this though, that is it doesn't give me an icon.
Doing it manually using the GUI, it does include an icon.
So any ideas on how I can embed the icon via the CLI?
Thanks,
Panarchy
-
May 11th, 2009, 09:20 PM
#9
Re: How-to specify the name of compiled output (*.exe) within C++ code?
/out is a command line parameter of link.exe.
Refer to the Command Line option in Project Properties -> Configuration Properties -> Linker.
Also check out the Command Line option in Project Properties -> Configuration Properties -> C / C++.
-
May 12th, 2009, 04:30 AM
#10
Re: How-to specify the name of compiled output (*.exe) within C++ code?
You could also copy/rename the file with Post build options from the settings dialog. I use VC++ 6 , maybe it's slightly elsewhere in dotnet.
-
May 12th, 2009, 11:29 PM
#11
Re: How-to specify the name of compiled output (*.exe) within C++ code?
I'm using Visual Studio 2008 Professional, specifically the Visual C++ component.
Just trying to work out how to compile my program via the command-line, including the icon.
Any ideas?
Thanks in advance,
Panarchy
-
May 13th, 2009, 12:12 AM
#12
Re: How-to specify the name of compiled output (*.exe) within C++ code?
You will get the whole command line parameter for the CL.EXE compiler and the LINK.EXE linker from the project properties that I mentioned in my earlier post. Copy and paste that into the command window to execute it from command line.
This is of course for a single cpp file. For multiple files you will need to create a makefile.
-
May 13th, 2009, 07:58 AM
#13
Re: How-to specify the name of compiled output (*.exe) within C++ code?
IN VC 2008 you can do the same as in VC6++
project settings => Build events => Post build-events:
REN $(TARGETPATH) newname.exe
or something like that.
-
May 14th, 2009, 01:48 AM
#14
Re: How-to specify the name of compiled output (*.exe) within C++ code?
Thanks, but how do I put that line directly into the .cpp file?
-
May 14th, 2009, 08:14 PM
#15
Re: How-to specify the name of compiled output (*.exe) within C++ code?
I got it to work by using the .res at the linking stage.
So I've now successfully worked out how to compile, the program via command-prompt, specifying the name, and having the correct icon.
Thanks for all your help.
Now, any ideas on how I can do this within my C++ code?
Thanks in advance,
Panarchy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|