Welcome, Guest. Please login or register.

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

Description:

0 Members and 1 Guest are viewing this topic.

Offline RodneyTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 1386
    • Show all replies
    • http://donthaveone.com/
GCC:C++:STL:vector
« on: April 01, 2003, 01:25:10 PM »
I've recently installed GCC and all seemed to be working fine until now.

I get very strange, unreadable (to me) error messages when i try to create a vector.

I am kinda still learning this vector stuff, and in doing so i m creating this little program to aswere one of my questions about vectors. But now i have a more important question. What do these errors mean?

Here is the code:

#include
#include
using namespace std;

int main ()
{
    vector v;
/*    int a = 3;
    int b = 2;
    v.push_back(a);
    v.push_back(b);
    v[0] = 10;
    v[1] = 10;

    printf ("%d %d",a ,b);
   */
}

As you can see, i've commented out most of the code so that im pretty sure the top line of function main() is causing the problemos.

Incase you cant tell from the program, im trying to find out if when adding an element to a vector, does the vector simply copy the element past into push_back() and put it in the vector, or does it obtain the objects address and add the reference in the vector?

However, thats not really the guestion i want answered anymore (although if you know it, that'd be good) The main question is, am i doing something wrong with this code, or is this a problem of my gcc? And has this been reported before? if so, is there a fix etc?

Heres the errors the above code is producing!

Projects:test> gcc -o vex vex.cpp
/t/cc8816321.o: Undefined symbol ___nw__FUlPv referenced from text segment
/t/cc8816321.o: Undefined symbol endl(ostream &) referenced from text segment
/t/cc8816321.o: Undefined symbol _cerr referenced from text segment
/t/cc8816321.o: Undefined symbol ___ls__7ostreamPCc referenced from text segment
/t/cc8816321.o: Undefined symbol ___ls__7ostreamPFR7ostream_R7ostream referenced from text segment
We are not Humans having a spirital experiance
We are Spirits having a Human experiance.
 

Offline RodneyTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 1386
    • Show all replies
    • http://donthaveone.com/
Re: GCC:C++:STL:vector
« Reply #1 on: April 01, 2003, 02:05:57 PM »
Good suggestion with the however it didnt work. Infact, it cant even find the file. So i tried and well, got the errors.

After some buggering around i tried copying iostream.h in gnu/lib/g++include/ to iostream and then included got the same errors again.

I tried
#define iostream iostream.h
#include

So that hopfuly the #define would filter down into the vector include files, however, got an error at the '.' in the #define, but thats not a problem... Cause it was just a stab in the dark.

I've got version 2.7.0 of gcc i believe. Is this good enough by peoples experiance?
We are not Humans having a spirital experiance
We are Spirits having a Human experiance.
 

Offline RodneyTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 1386
    • Show all replies
    • http://donthaveone.com/
Re: GCC:C++:STL:vector
« Reply #2 on: April 01, 2003, 02:38:30 PM »
Well thanx for you help anyway. Ill have another look at it tomorrow, and possibly reinstall or  upgrade (if thats possible, this was the only installation of gcc i could find on aminet).

For now, im off to bed!
We are not Humans having a spirital experiance
We are Spirits having a Human experiance.
 

Offline RodneyTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 1386
    • Show all replies
    • http://donthaveone.com/
Re: GCC:C++:STL:vector
« Reply #3 on: April 02, 2003, 04:39:41 AM »
Quote

trgse wrote:
in my opinion you should install a newer version of GCC you are not even using egcs which means it's oooolllddd.


Yer, this makes sence. A search on aminet returned some Warp UP stuff but nothing that would suggest it is a native C++ compiler for 68k AmigaOS.

it also returned egcs-src.lha . Which im guessing is the source of the compiler. Do you know where i can get the binaries from?

Quote

second thing (this aplies to anyone doing C++ with GCC) is to install stlport instead standard gnu stl implementation, stlport can be found at http://www.stlport.org


Whats the advantages of STLport and why would you recommended over the standard gnu implementation?
We are not Humans having a spirital experiance
We are Spirits having a Human experiance.
 

Offline RodneyTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 1386
    • Show all replies
    • http://donthaveone.com/
Re: GCC:C++:STL:vector
« Reply #4 on: April 02, 2003, 01:26:58 PM »
Quote

trgse wrote:
in my opinion you should install a newer version of GCC you are not even using egcs which means it's oooolllddd.


Yup :) good point. Problem. There seems to be now egcs on aminet except for some Warp Up stuff. There was a page which some guy had m68k hosted and targeted binaries there, and all the warpup stuff too, but non of the links work.

And then the ftp site of back2roots had 2 version of 68020 binaries for egcs... i think one was alpha 1.0.3 and the other one looked like a stable 1.1.2...
Is this the stuff i want? Or is there a more up to date version?


Quote

second thing (this aplies to anyone doing C++ with GCC) is to install stlport instead standard gnu stl implementation, stlport can be found at http://www.stlport.org


And this sounds a little weird. If i develop useing these libraries, will i still be able to port my stuff to other platforms and use the gnu STL's?

What advantages does this give me? I think at their site i saw something about optomisations. Do you have any other reasons for why their good to use?

Do i need to get an Amiga specific version of it?
We are not Humans having a spirital experiance
We are Spirits having a Human experiance.
 

Offline RodneyTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 1386
    • Show all replies
    • http://donthaveone.com/
Re: GCC:C++:STL:vector
« Reply #5 on: April 02, 2003, 01:29:58 PM »
Quote

CodeSmith wrote:
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)


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! :)
We are not Humans having a spirital experiance
We are Spirits having a Human experiance.
 

Offline RodneyTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 1386
    • Show all replies
    • http://donthaveone.com/
Re: GCC:C++:STL:vector
« Reply #6 on: April 03, 2003, 09:42:09 AM »
Quote

nyteschayde wrote:
The code compiles for me. The output is 3 2. So the values stored in the vector are not stored by reference. As for your compilation errors... try installing a new version.


Thanx heaps :) but thats not what i wanted to hear :) That is, i was hopeing that'd be passed by reference. Not to worry.
We are not Humans having a spirital experiance
We are Spirits having a Human experiance.
 

Offline RodneyTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 1386
    • Show all replies
    • http://donthaveone.com/
Re: GCC:C++:STL:vector
« Reply #7 on: April 03, 2003, 09:43:26 AM »
Quote

Piru wrote:
@Rodney

ftp://ftp.geekgadgets.org/pub/geekgadgets/amiga/m68k/alpha/gcc/

2.95.3


Thank you very much, just what i wanted :)

Quote

...there seems to be braind new 3.2.2 there too, but you'd better stick with 2.95.3 for now...



Think i'll go the 3.2.2 :) the newer the better :). Unless 3.2.2 is in alpha or beta then i might go the 2.95.3 :}
We are not Humans having a spirital experiance
We are Spirits having a Human experiance.
 

Offline RodneyTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 1386
    • Show all replies
    • http://donthaveone.com/
Re: GCC:C++:STL:vector
« Reply #8 on: April 03, 2003, 11:00:07 AM »
Quote

Piru wrote:
Don't. It is definetely very much alpha. Don't use it. Stick with 2.95.3, this saves you a LOT of headaches.


Hey i almost forgot, i was told to upgrade to egcs, which to me makes sence, because egcs is now the official gnu compiler i believe.

That is, i thought egcs, was gcc ... infact i forget when gcc developement stoped and egcs started. somewhere in the 2.x's.

Ummmm so i guess im confused over the two different directories now :) theres the
alpha/gcc and
alpha/egcs

So, which one is better? I would have though egcs was uptodate, but ithough gcc 3 was egcs :}
We are not Humans having a spirital experiance
We are Spirits having a Human experiance.
 

Offline RodneyTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 1386
    • Show all replies
    • http://donthaveone.com/
Re: GCC:C++:STL:vector
« Reply #9 on: April 03, 2003, 12:00:07 PM »
Quote

in my opinion you should install a newer version of GCC you are not even using egcs which means it's oooolllddd.


I think what he was saying is that the version of gcc i had, hadnt even split to egcs yet.

But where i got my information for egcs was i think the BSD sources. I was trying to find the latest compiler for OpenBSD and i could only find egcs. In the read me it said something like, gcc dev stoped, and egcs took over and because the official compiler for either, bsd or gnu... not sure...
We are not Humans having a spirital experiance
We are Spirits having a Human experiance.