Firefox 16, a treat for developers http://t.co/cnd27CzT
run a C++ program from terminal
Linux doesn’t have extensions … it’s not a brain dead OS like Windows, at least not when it comes to actually developing anything.
To make life easy, however, there are certain conventions.
If I have a c++ source file called foo.cpp and I run
gcc -c -Wall -g foo.cpp
The program gcc will understand that foo.cpp is a C++ source file (not a fortran, C or java source file) and generate an object file with the extension .o
If I then do:
gcc -g -L/usr/lib -lstdc++ foo.o
gcc will understand that i intend to invoke the linker (ld) and use libstdc++.so in the /usr/lib directory, also — add debugging symbols.
Because I didn’t specify a target, gcc will produce a file a.out and set executable permissions on it.
I type:
./a.out
On the other hand I can specify a target with gcc:
gcc -g -L/usr/lib -lstdc++ foo.o -o foo.xxx.blah
./foo.xxx.blah
It makes no difference what I call the compiled binary executable, linux could care less.
Of course, for a simple program, I would skip the intermediate object:
gcc -g -Wall -lstdc++ foo.cpp -o foo
and now gcc understands that I want to compile a c++ source file, link it to the system’s standard c++ shared object and put the result (with debugging symbols) in a file called foo.
Or I can make my life even easier:
g++ -g -Wall foo.cpp -o foo
g++ is a program that does everything gcc did in the example above, but it only deals with c++ code and linkage.
Enjoy
Like us on Facebook
This week Top Posts 
Top Things to do After Installing Ubuntu 13.04 ‘Raring Ringtail’ : Ubuntu 13.04 Raring Ringtail final is almost out. The final release it scheduled for release on Apri...0 comment(s) |
Install lamp with 1 command in Ubuntu 12.10, 13.04 Raring Ringtail & LinuxMint13 : Updated: 10/09/2012 :LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform ...0 comment(s) |
Howto: Upgrade to Ubuntu 13.04 Raring Ringtail from 12.04, 12,10 | Desktop & Server : Updated 05-04-2013: Ubuntu 13.04 Raring Ringtail will be released Soon, If you have ubuntu 12,10, 12...0 comment(s) |
How to use Remote Desktop in Ubuntu : Sometimes, we need to access our computer from other locations when we’re not at home and such. This...0 comment(s) |
Configure conky-Lua in Ubuntu (12.10 & 13.04 Raring Ringtail), Fedora, debian and LinuxMint | Howto Conky : Updated 05-04-2013: Conky is a free, light-weight system monitor for X, that displays any informatio...0 comment(s) |
Unix/Linux File Recognition. Did You Know? : Did you know that Unix and Linux has no concept of a file extension? What is a file name extension?
...1 comment(s) |
Recent Posts
- Unix/Linux File Recognition. Did You Know?
- Migrate from MySQL to MariaDB in FreeBSD
- Connect Your Android Galaxy Tablet to Ubuntu via USB
- ElementaryOS Beta 1 and 2 Comparison and Review
- Introduction to the Linux Command Line
- A Secure Password
- Linux Kernel 3.10. It’s BIG!
- Monitoring Users Activity Using psacct or acct Tools in Linux
- Run Your Own Social Network Using elgg on RHEL / CentOS and Scientific Linux
- Getting Debian 7.0 ‘Wheezy’ Up and Running
Recent Comments



















Ambiton
| #
Thank you very much Chris :)
Lolman
| #
in cmd
Oliver
| #
Do you think that it works on a Macbook Air 1,1?… ohh and, it must be installed in a different partition than Mac OS X, right?… can´t have i installed only Ubuntu on my hard drive?
Brandon Hawkins
| #
thanks
Nova
| #
I wonder if there is a way to create your own themes.