Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gcc compiler

Status
Not open for further replies.

NPG

Programmer
Mar 9, 2001
9
0
0
GR
Hi i am a new linux user, my problem is that after compiling a program with gcc, there is not created any .o file. So in other words, i dont know how to run my c and c++ programs.Thanks!
 
Well, if you just do:

gcc source.c

You get a file called a.out

To run this, type:
./a.out

But, you can say gcc -o name source.c

where name is the name of your file you want to create as executable. Type:
man gcc

for more information.

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
If you want it to create a .o file do gcc -c filename.c, it will create filename.o. (Use g++ instead of gcc for c++ files)
 
I have my .o file with no errors, how can i execute it?
 
show us what you are typing to generate teh .o file, and then we'll all know that we're talking about the same thing, post as much info as you can.

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
Thanks it works! The mistake was that i typed ./ foo.
I want also to tell my how should i give my argc and argv parameters to my main function from console.
 
just do:

./foo arg1 arg2 arg3

Remember,
argv[0] is the progname, and argv[1] is arg1.

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top