using the vector template class

David Churches David.Churches@astro.cf.ac.uk
Wed Jan 2 05:57:00 GMT 2002


Hi,

I am trying to use GCC to compile C++ code, but I am unable to use 
various classes such as vector and valarray. To illustrate this, I have 
been trying to compile the following piece of very simple code. I am using 
RedHat Linux 7.0 running on a Dell Latitude laptop.

Here is the code:


#include <vector>

int main ()
{

   vector <int> ivec(5);
   return 0;
}


I try to compile it using the following command:

g++ -o trivial trivial.cc

The error message I get is

trivial.cc: In function `int main()':
trivial.cc:6: `vector' undeclared (first use this function)
trivial.cc:6: (Each undeclared identifier is reported only once for each 
   function it appears in.)
trivial.cc:6: parse error before `>' token


I have recently re-installed GCC, and it looks like I am not linking up 
to the header files. Do I have to set any flags so that GCC knows where 
the header files are ? I have tried using -I/usr/local/include/g++-v3 on 
the command line, but it makes no difference.


Thanks in advance for any help,

David Churches.



-------------------------------------------------------------
David Churches
Department of Physics and Astronomy
Cardiff University, PO Box 913, Cardiff, CF2 3YB, U.K.
Phone: + 44-29-20874785, 20875121 (direct line) Fax: + 44-29-20874056
d.churches@astro.cf.ac.uk



More information about the Gcc-help mailing list