Welcome, Guest. Please login or register.

Author Topic: GCC:C++:STL:vector  (Read 6514 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline CodeSmith

  • Sr. Member
  • ****
  • Join Date: Sep 2002
  • Posts: 499
    • Show all replies
Re: GCC:C++:STL:vector
« on: April 02, 2003, 07:59:35 AM »
I haven't used g++ for quite a while now, but IIRC something you needed to do was, if you're using gcc to do the linking for you (eg gcc -omybin myobj1.o myobj2.o myobj3.o) is that you have to use the g++ command to do this, as gcc is the C compiler and g++, being the C++ compiler, does a bit more.  If you're using ld to link the final binary, you'd have to add "-lstdc++" or "-lstdcxx" to your command line (that's part of that extra stuff g++ does).  That library has all the stream code in it.

So, according to your example, you should be doing this:

Projects:test> g++ -o vex vex.cpp

(if g++ is not recognized as a command, try gxx)
 

Offline CodeSmith

  • Sr. Member
  • ****
  • Join Date: Sep 2002
  • Posts: 499
    • Show all replies
Re: GCC:C++:STL:vector
« Reply #1 on: April 03, 2003, 04:36:45 AM »
Quote

Rodney wrote:

i dont know, but maybe what your talking about is Amiga specific. But on Unix, gcc does everything. infact, gcc is just a unified interface for g++ and the linker etc... gcc calls c++ if the code is in C++

eg, i was writing c++ in a file with the extension .c. gcc had errors... i changed the named to cpp and then it worked :). Gcc also supports the file extension .c++ for C++ code.

Anyway, thats what i thought! :)


Gcc will guess the language from the file extension, so you would have had errors with a cpp file called #?.c
I'm pretty sure the g++ thing is not an Amiga-only thing, because I first found out about it when I was doing some MS-DOS coding  :-D
If you don't have g++ on your platform, just add the "-lstdc++" switch to the last time you run gcc, or to the time you call ld, in your makefile.