> Programming Languages > C++
Various Topics Home | Disclaimer | Report Adult Posts

Various Topics on C++



C++ - "Making gcc a windows .exe file" in Programming Languages


Old 02-08-2004   #1
..ct.. ..zar..
 
Default Re: Making gcc a windows .exe file

"cplusplus" <cplusplus@linux.local> wrote...
> Hi, I just started a C++ cource in school and am using
> gcc --version 3.3.1 (Suse Linux 9.0). Everything is
> working great except I need to have the exacuatable in
> ".exe" format and be able to run on a windows machine.
> I asked my teacher how this could be done and he told
> me by using the "-o" option or I could
> simply rename the a.out file to "helloworld.exe".


Your teacher played a cruel joke on you. The name of the
file and the internal format of the executable are not at
all connected.

> I used the following command:
>
> g++ -ansi -pedantic -Wall -o helloworld.exe helloworld.cpp
>
> It works great, but I was a bit skeptical so I put the file
> on a floppy and tried opening it on a windows machine. The
> file wont open and says that there is an error reading the file.
> I ***ume this is because the program is a linux exacuatable file.
> Is there a command I can use to make it an actual windows .EXE file?


No.

> I tried looking through the man page and just couldn't find it.


You need what is known as a "cross-compiler". The compiler
that comes with your OS is only going to produce executables
for that OS.

Please ask in a newsgroup dedicated to your platform (either
one would do) since here it is off-topic. Yours is not a C++
_language_ problem but a C++ _compiler_ problem.

Victor


 
Old 02-08-2004   #2
..sse.. ..nnek..
 
Default Re: Making gcc a windows .exe file

cplusplus wrote:
> Hi, I just started a C++ cource in school and am using
> gcc --version 3.3.1 (Suse Linux 9.0). Everything is
> working great except I need to have the exacuatable in
> ".exe" format and be able to run on a windows machine.
> I asked my teacher how this could be done and he told
> me by using the "-o" option or I could
> simply rename the a.out file to "helloworld.exe".


I think maybe your instructor misunderstood what you were asking him.
He probably thought you were using a Windows version of GCC, and you
just wanted to know how to specify the name of the output file.

GCC actually can build executables for different platforms. You might
have to rebuild your compiler to get it to target Windows, though.

You should really ask this question on the newsgroup gnu.gcc.help.
comp.lang.c++ is for discussion of the C++ language, rather than
particular development tools like GCC. See the welcome message for this
group:

http://www.slack.net/~shiva/welcome.txt

Regards,

Russell Hanneken
rghanneken@pobox.com
Remove the 'g' from my address to send me mail.
 
Old 04-10-2004   #3
..be.. ..amo..
 
Default Re: Making gcc a windows .exe file

There are ports of gcc to windows (ie: dev-cpp, is a windows IDE which uses
the ming gcc compiler on a windows box to compile windows binaries.) I'd
just install windows 98/95 and use it to compile your projects. Compile,
debug, etc... on your *nix install and then run your win install and open up
dev-c++/cywin etc... and compile.

If you do some googling someone's probably already done from a *nix box.
Probably some includes and special params to gcc or a different source tree
of gcc with win32 binary support. google it up


 
Old 12-20-2005   #4
..l..pl..
 
Default Making gcc a windows .exe file

Hi, I just started a C++ cource in school and am using
gcc --version 3.3.1 (Suse Linux 9.0). Everything is
working great except I need to have the exacuatable in
".exe" format and be able to run on a windows machine.
I asked my teacher how this could be done and he told
me by using the "-o" option or I could
simply rename the a.out file to "helloworld.exe".
I used the following command:

g++ -ansi -pedantic -Wall -o helloworld.exe helloworld.cpp

It works great, but I was a bit skeptical so I put the file
on a floppy and tried opening it on a windows machine. The
file wont open and says that there is an error reading the file.
I ***ume this is because the program is a linux exacuatable file.
Is there a command I can use to make it an actual windows .EXE file?
I tried looking through the man page and just couldn't find it.
Thanks for helping a newbie.

--Cameron
 

Thread Tools
Display Modes





Powered by vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0