Click to See Complete Forum and Search --> : gcc newbie
hi
how do we run our source code using gcc..?
cause the gcc command would only compile the source code, right?
thanx a lot
bye
I don't know if this will help but there's a few help files:
http://justlinux.com/nhf/Installation
Especially this one:
http://justlinux.com/nhf/Installation/Compiling_Software.html
Jme
emm...sorry.... it seems that i don't get my message through...
what actually i'm trying to do is.. i'm writing programs using C++... and i want to use gcc as the compiler... but i don't know how to view the output file of my program...
thanx a lot for helping
What do you mean? Run the program?
./program
just run
./program
after we have compiled the source code,is it?
thanx a lot
bwkaz
12-17-2003, 11:08 PM
And for a C++ program you need to use g++ instead of gcc, but other than that, yeah.
Also, if you don't tell gcc (or g++) the filename to write its output to (by passing -o progname on its command line), it'll write to the file a.out (assembler output). So if you just g++ mycppfile.cpp, you would run the resulting program with ./a.out; if you did a g++ -o myprog mycppfile.cpp, then you would run ./myprog instead.
Citadel
12-19-2003, 04:52 PM
You can use gcc but you have to tell the inker to load the C++ library:
gcc program.cpp -lstdc++
Citadel
12-19-2003, 05:54 PM
This will vary between Linux platforms but here is another way to do it:
gcc prog.cpp /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/libstdc++.a
or:
gcc prog.cpp /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/libstdc++.so
...because all of the object files for the c++ or whatever library you are loading are contained in files with the '.so' or the '.a' extension. If one doesn't work, try the other.
I had the same exast problem when I started. Now my syntax is just:
$ g++ foo.cc -o foo.exe
I use foo.exe because I'm used to Windows so much but I think the output file can be just about any name. I still am getting hold of the debugger though.