Jump to content

How-to specify the name of compiled output (*.exe) within C++ code?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
61 replies to this topic

#1
Panarchy

Panarchy

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 258 posts
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

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
You can't. The project file will tell the compiler what output name to use. If you ever use a different compiler, it will probably be the -o [outputname] option.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Panarchy

Panarchy

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 258 posts
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

:D

Problem solved!

Disadvantages;
- Have to do an Alt-Tab :rolleyes:
- Command-Prompt sucks, as I need to right-click, Paste Posted Image

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

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,715 posts
There's an option in the Project settings called "Output Name" or something like that. You might want to take a look at that...

#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Panarchy: that's how I code, except I use jEdit instead of VS.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#6
Panarchy

Panarchy

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 258 posts

WingedPanther said:

You can't. The project file will tell the compiler what output name to use. If you ever use a different compiler, it will probably be the -o [outputname] option.

/OUT is the command. However, I can't get it to work. Some help here... please?

Thanks,

Panarchy

#7
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
dargueta may know. I don't use Visual Studio.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#8
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,715 posts
Try this:
/OUT:programname.exe

Notice that there are no spaces.

#9
Panarchy

Panarchy

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 258 posts
Hi

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

#10
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,715 posts
Yep. You need to create two files aside from the icon, and add them to your project. Make sure you have one icon that's 32x32, optional ones are 16x16 and 48x48.

resource.h
#define    IDI_MYICON    101
#define    IDI_SECONDICON    102

resource.rc
#include "resource.h"

IDI_MYICON ICON "icon.ico"
IDI_SECONDICON    ICON    "icon2.ico"

Be sure you compile the project as a Win32 application, NOT a console application.

Win32 Programming (Tutorial on embedding/using resources is the second on the left)

#11
Panarchy

Panarchy

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 258 posts
Thanks, however the icon compiles properly and is embedded within the .exe, when doing the compiling via the GUI.

However, when using the aforementioned commands, I don't get an icon.

Can you please help me out here?

Thanks in advance,

Panarchy

#12
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,715 posts
An icon where, exactly? Do you want the icon to show as the program's thumbnail in Explorer, or in the upper left-hand corner? Please post your icon - it might have the wrong dimensions. (Also, make sure that both the resource files are added to your project.)