Whenever I try to compile something using the iostream library, gcc pumps out a lot of errors. Here's the gcc -v -save-temps screen: Using built-in specs. Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-cpu=generic --build=i386-redhat-linux Thread model: posix gcc version 4.3.0 20080428 (Red Hat 4.3.0-8) (GCC) Here's the errors i get get when compile (gcc src/mycode.cpp -o bin/myprog): gcc src/reg.cpp -o bin/reg /tmp/cc8kjHpW.o: In function `main': reg.cpp:(.text+0x1c): undefined reference to `std::cout' reg.cpp:(.text+0x21): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' reg.cpp:(.text+0x29): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)' reg.cpp:(.text+0x31): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))' /tmp/cc8kjHpW.o: In function `__static_initialization_and_destruction_0(int, int)': reg.cpp:(.text+0x60): undefined reference to `std::ios_base::Init::Init()' reg.cpp:(.text+0x65): undefined reference to `std::ios_base::Init::~Init()' /tmp/cc8kjHpW.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0' collect2: ld returned 1 exit status I know your page said you didn't want a code snippet but I can't help but think it's relevant (I might just be overlooking something): #include <iostream> using namespace std; int main(int argc, char *argv[]) { std::cout<<"asdf"<<endl; return 0; } Even something that simple won't work.
Subject: Re: New: can't use iostream library Sent from my iPhone On Sep 28, 2008, at 7:44 PM, "hadmanysons at gmail dot com" <gcc-bugzilla@gcc.gnu.org > wrote: > Whenever I try to compile something using the iostream library, gcc > pumps out a > lot of errors. Here's the gcc -v -save-temps screen: > Using built-in specs. > Target: i386-redhat-linux > Configured with: ../configure --prefix=/usr --mandir=/usr/share/man > --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla > --enable-bootstrap --enable-shared --enable-threads=posix > --enable-checking=release --with-system-zlib --enable-__cxa_atexit > --disable-libunwind-exceptions > --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java- > awt=gtk > --disable-dssi --enable-plugin > --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre > --enable-libgcj-multifile --enable-java-maintainer-mode > --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava- > multilib > --with-cpu=generic --build=i386-redhat-linux > Thread model: posix > gcc version 4.3.0 20080428 (Red Hat 4.3.0-8) (GCC) > > Here's the errors i get get when compile (gcc src/mycode.cpp -o bin/ > myprog): > gcc src/reg.cpp -o bin/reg Use g++ to link instead of gcc. > > /tmp/cc8kjHpW.o: In function `main': > reg.cpp:(.text+0x1c): undefined reference to `std::cout' > reg.cpp:(.text+0x21): undefined reference to `std::basic_ostream<char, > std::char_traits<char> >& std::operator<< <std::char_traits<char> >> (std::basic_ostream<char, std::char_traits<char> >&, char const*)' > reg.cpp:(.text+0x29): undefined reference to `std::basic_ostream<char, > std::char_traits<char> >& std::endl<char, std::char_traits<char> >> (std::basic_ostream<char, std::char_traits<char> >&)' > reg.cpp:(.text+0x31): undefined reference to `std::basic_ostream<char, > std::char_traits<char> >::operator<<(std::basic_ostream<char, > std::char_traits<char> >& (*)(std::basic_ostream<char, > std::char_traits<char> >> &))' > /tmp/cc8kjHpW.o: In function > `__static_initialization_and_destruction_0(int, > int)': > reg.cpp:(.text+0x60): undefined reference to > `std::ios_base::Init::Init()' > reg.cpp:(.text+0x65): undefined reference to > `std::ios_base::Init::~Init()' > /tmp/cc8kjHpW.o:(.eh_frame+0x11): undefined reference to > `__gxx_personality_v0' > collect2: ld returned 1 exit status > > I know your page said you didn't want a code snippet but I can't > help but think > it's relevant (I might just be overlooking something): > > #include <iostream> > > using namespace std; > > int main(int argc, char *argv[]) > { > std::cout<<"asdf"<<endl; > return 0; > } > > > Even something that simple won't work. > > > -- > Summary: can't use iostream library > Product: gcc > Version: 4.3.0 > Status: UNCONFIRMED > Severity: major > Priority: P3 > Component: c++ > AssignedTo: unassigned at gcc dot gnu dot org > ReportedBy: hadmanysons at gmail dot com > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37671 >
Indeed.
That worked all right. Am i just stupid or was there some change to the gcc package I was unaware of, because gcc used to compile c++ code just fine (at least in the older version of Fedora and as old as RedHat 6.2), that i was aware of.