View Full Version : g++ how to
newbie_101
March 24th, 2007, 05:39 PM
hi all
ive been programing 4 the last 2 week in window. the other day i installed ubuntu on my machine. now i want to do my programing in ubuntu. im using the gEdit and G++ method. but its not like windows...
so far i type in the terminal:
g++ HelloWorld.cpp
it created 'a.out'. What do i do now.
thanx,
Newbie_101.
monkeyking
March 24th, 2007, 05:57 PM
To run your program
./a.out
newbie_101
March 24th, 2007, 05:59 PM
thank you monky king
monkeyking
March 24th, 2007, 06:00 PM
btw if you want your program to have a more sensible name you can do stuff like.
g++ -o smartname HelloWorld.cpp
samjh
March 25th, 2007, 09:14 AM
To get an output file:
g++ -o outputfile.bin sourcecode.cpp
To display all compiler warnings:
g++ -Wall -o outputfile.bin sourceode.cpp
To generate debugging information (necessary if you wish to use gdb for debugging):
g++ -g -o outputfile.bin sourceode.cpp
Use -O, -O1, -O2, or -O3 for speed optimisations:
g++ -O2 -o outputfile.bin sourcecode.cpp
Use -s to strip symbols, which reduces output file size"
g++ -s -o outputfile.bin sourcecode.cpp
You can combine all that:
g++ -s -O2 -Wall -o outputfile.bin sourcecode.cpp
For more info: http://www.die.net/doc/linux/man/man1/g++.1.html
lnostdal
March 25th, 2007, 09:47 AM
Also see http://www.network-theory.co.uk/docs/gccintro/ (great for beginners) and of course http://gcc.gnu.org/onlinedocs/gcc/ (and for the preprocessor: http://gcc.gnu.org/onlinedocs/cpp/ ).
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.