Compiling C++ (this should be easy.. maybe)

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
fish
Posts: 25
Joined: Wed Feb 08, 2006 5:12 am

Compiling C++ (this should be easy.. maybe)

Post by fish »

Hey all, this is my 1st post so, hello, long time lurker 1st time poster etc etc.

I've a question, it's most likely very easy to answer (and probably has been donr before), but seing as I have round about 0 experience using linux or any non-IDE programming (other than a little UnrealScript and GBA stuff), I'm stuck.

All I want to do is compile C++ files instead of C, becuase I'm happier programming C++, I like my classes if nothing else:) I used the forum search but I think it sees it as searching for "C"+""+"" and returns 0 results.

I assume I have to change (or insert) a g++ instead of gcc in the makefile.

Any suggestions? (apologies for being such a newb:p)
nicoli_s
Posts: 12
Joined: Mon Jan 02, 2006 7:23 am
Contact:

Post by nicoli_s »

all I did was name my files .cpp instead of .c and it did it automatically for me
sandberg
Posts: 90
Joined: Wed Oct 05, 2005 1:25 am
Location: Denmark

Post by sandberg »

You only have to link with the stdc++ library, no other changes is needed.

So add

Code: Select all

-lstdc++
to the LIBS statement in your makefile.
Br, Sandberg
fish
Posts: 25
Joined: Wed Feb 08, 2006 5:12 am

Post by fish »

Sorted now, I'd tried renaming to .cpp but it threw up a bunch of errors about undefined functions. Turns out it was working, but I hadn't used

extern "C" { }

around my #includes, but the compiler didn't remind me that the non-standard .h files I'm using aren't c++, my own fault i should have noticed that.

ta for all the help.
Post Reply