PDA

View Full Version : Need GNU C++ help



mover50
11th October 2004, 09:31 PM
Need help on doing a simple compile of my C++ program.

All I have to go on is the man gcc and I either get a file not found or ' linker input file unused because linking not done' message.

I need some help on learning how to use GNU gcc along with learning C++ ( I already have a C++ programming book, but it does not cover GNU CC) and I need something better than man gcc.

Thanks,

Kent (the worrier)

Chas.H
11th October 2004, 09:42 PM
Good information can be found here (http://www.fedoraforum.org/forum/showthread.php?t=23058)

mover50
11th October 2004, 09:48 PM
Already checked out that thread. It does not address my problem.

Thanks,

Chas.H
11th October 2004, 09:54 PM
When in doubt, go to the source:
Gnu GCC manuals (http://www.gnu.org/software/gcc/onlinedocs/)

Chas.H
11th October 2004, 11:47 PM
Now that I'm home on my real (non-Windows) machine I can give a little starter. I Don't know your experience, so I assume newbee... ;) for starters ;)

On your desktop, create a new folder[right-click|create folder] and call it whatever.

Open terminal and cd to that directory and type: gedit hello.cpp

gedit will open asking if you want to create hello.cpp... you do.

Put in the following code:


#include <iostream.h>
main()
{
cout << "Hello World" << endl;
return 0;
}

Save and close the editor and you are ready to compile and build the app.
type: g++ hello.cpp -o hello

You will see some little warnings but don't worry about them.
type ls -l
This will list the files in your directory. "hello" will be there listed as an executable (the last x in the first column).
type ./hello to run it

Hope this helps... ;)

mover50
12th October 2004, 01:30 AM
Thanks Chas,

Here is what happens when I do those steps.
When I enter g++ and get a command not found.
If I try gcc helllo.cpp -o hello I get, 'gcc: installation problem, cannot exec `cc1plus': No such file or directory'.

Thanks for taking the time to help me on this. One step at a time.

Kent (the worrier)

Harryc
12th October 2004, 02:48 AM
# yum install gcc-c++

Chas.H
12th October 2004, 02:59 AM
It sounds like you are missing some of the compiler.
Did you install Fedora core 2?
- and -
Did you install everything? (last item on the list of things to install)


note:
g++ is for c++ *.cpp

gcc is for traditional (Kerrigan & Richie) C


:rolleyes: Also***
Check the menu item Programming > Kdevelop.

This is a really useful tool. You can start with the built in "Hello World" code just waiting to be built. On the menu click build | Build Project. This actually calls the same compiler that you seem to be missing and may give guidance on how to fix the problem.

I haven't had the problem of the compiler failing, except when I write bad code, :rolleyes: so I have no experience fixing it.

I'm sure there others here that can lend their help as well:
Nottingham Forest or Portsmouth fans perhaps? ;)

Let me know how it goes.

Chas.H
12th October 2004, 03:02 AM
# yum install gcc-c++

Good Call!

I wanted to mention yum but I had no idea what the packagename was.

Thanks, Harryc

mover50
12th October 2004, 04:55 AM
Thanks Chas and Harry,

the yum install gcc-c++ did the trick.

How do i give you some points?

The help you guys gave me here even though quit basic was top notch and it got me over what seemed liked a major hurdle.
I asked the same question several other places and yours was the only that helped.

Mucho thanks,

Kent

Harryc
12th October 2004, 09:09 AM
You're welcome. To give reputation points, just click on the reputation link under the members name in any post. Good luck.

Chas.H
12th October 2004, 01:18 PM
Glad you got it sorted out.

It helped me as well, giving me a refresher on the command line compiler. :)

I see by your profile that you are a well experienced programmer. Are you new to C and C++?

mover50
12th October 2004, 05:08 PM
Glad you got it sorted out.

It helped me as well, giving me a refresher on the command line compiler. :)

I see by your profile that you are a well experienced programmer. Are you new to C and C++?

Not 100% new. Tried to get into it when Borland came out with their version of C (about 12 years ago, I think). There was not much on C or C++ back then. I know the basics and am picking it up again.
Also learning Pearl and Linux as well.

Long history of mainframe stuff, from assembler fortran, cobol and many that are not even around anymore.
I have been mostly out of it since 1999 but, like to keep my brain working and occupied.

Curretnly working on my own little project along with my wife (also a programmer). She is doing it in Foxpro for windows, and I am looking at doing it with pearl LWP or C# for linux.

Gotta tell ya, it's lots more fun doing it on your own without the pressures of a paying job.

Thanks and regards,

Kent :cool: