From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020827 Description of problem: For some reason in the g++ or libstdc++ installation the standard library types do not seem to be visible to the compiler. These are trivial programs which work fine on Redhat 7.3. This is serious since it is impossible to compile any useful C++ program. Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: % cat bug.cc #include <sstream> #include <string> main() { string s("Hello standard library.\n"); cout << "hello world\n" << s; } Actual Results: g++ -o bug bug.cc bug.cc: In function `int main()': bug.cc:9: `string' undeclared (first use this function) bug.cc:9: (Each undeclared identifier is reported only once for each function it appears in.) bug.cc:9: parse error before `(' token bug.cc:10: `cout' undeclared (first use this function) bug.cc:10: `s' undeclared (first use this function) [mbk@lyapunov ffs-adaptive]% Expected Results: % g++ -o bug bug.cc % ./bug hello world Hello standard library. % Additional info: g++ -v [mbk@lyapunov ffs-adaptive]% g++ -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit Thread model: posix gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) [mbk@lyapunov ffs-adaptive]% % rpm -q -i gcc Name : gcc Relocations: (not relocateable) Version : 3.2 Vendor: Red Hat, Inc. Release : 7 Build Date: Tue 03 Sep 2002 08:04:33
For reference: [ali@damascus tt]$ cat /etc/redhat-release Red Hat Linux release 8.0 (Psyche) [ali@damascus tt]$ cat bug.cpp #include <iostream> #include <string> main() { std::string s("Hello standard library.\n"); std::cout << "hello world\n" << s; } [ali@damascus tt]$ g++ -o bug bug.cpp [ali@damascus tt]$ ./bug hello world Hello standard library. Cheers, -Ali
The standard defines string, cout etc. in std namespace. So, either you do ali suggested, or you add using std::string; using std::cout; or you add using namespace std;