LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   GNU doesn't seem to recognize libstdc++ (https://www.linuxquestions.org/questions/linux-newbie-8/gnu-doesnt-seem-to-recognize-libstdc-373052/)

MasterOfTheWind 10-14-2005 11:25 AM

GNU doesn't seem to recognize libstdc++
 
Hi!

Just installed debian and got following problem: When trying to compile a simple program that uses some aspects of the std-lib (like vectors, strings and so on), I get following error messages on linking:

Code:

g++ -lm -O3 -ffast-math -Wall -I. main.o utils.o vector.o color.o matrix.o transform.o shape.o sphere.o -o iray
utils.o: In function `__gnu_cxx::__common_pool_base<__gnu_cxx::__pool, true>::_S_initialize()':
utils.cpp:(.gnu.linkonce.t._ZN9__gnu_cxx18__common_pool_baseINS_6__poolELb1EE13_S_initializeEv[__gnu_cxx::__common_pool_base<__gnu_cxx::__pool, true>::_S_initialize()]+0xd2): undefined reference to `__gnu_cxx::__pool<true>::_M_initialize()'
utils.o: In function `__gnu_cxx::__common_pool_base<__gnu_cxx::__pool, true>::_S_initialize_once()':
utils.cpp:(.gnu.linkonce.t._ZN9__gnu_cxx18__common_pool_baseINS_6__poolELb1EE18_S_initialize_onceEv[__gnu_cxx::__common_pool_base<__gnu_cxx::__pool, true>::_S_initialize_once()]+0x101): undefined reference to `__gnu_cxx::__pool<true>::_M_initialize()'
utils.o: In function `__gnu_cxx::__mt_alloc<NumValue, __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true> >::allocate(unsigned int, void const*)':
utils.cpp:(.gnu.linkonce.t._ZN9__gnu_cxx10__mt_allocI8NumValueNS_20__common_pool_policyINS_6__poolELb1EEEE8allocateEjPKv[__gnu_cxx::__mt_alloc<NumValue, __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true> >::allocate(unsigned int, void const*)]+0x2a1): undefined reference to `__gnu_cxx::__pool<true>::_M_initialize()'
color.o: In function `Color::getString()':
color.cpp:(.text+0x16d): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_empty_rep_storage'
color.cpp:(.text+0x175): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_empty_rep_storage'
color.o: In function `char* std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_construct<char*>(char*, char*, std::allocator<char> const&, std::forward_iterator_tag)':
color.cpp:(.gnu.linkonce.t._ZNSs12_S_constructIPcEES0_T_S1_RKSaIcESt20forward_iterator_tag+0x26): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_create(unsigned int, std::allocator<char> const&)'
color.cpp:(.gnu.linkonce.t._ZNSs12_S_constructIPcEES0_T_S1_RKSaIcESt20forward_iterator_tag+0x73): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_empty_rep_storage'
color.cpp:(.gnu.linkonce.t._ZNSs12_S_constructIPcEES0_T_S1_RKSaIcESt20forward_iterator_tag+0x79): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_empty_rep_storage'
color.o: In function `std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::seekoff(long, std::_Ios_Seekdir, std::_Ios_Openmode)':
color.cpp:(.gnu.linkonce.t._ZNSt15basic_stringbufIcSt11char_traitsIcESaIcEE7seekoffElSt12_Ios_SeekdirSt13_Ios_Openmode+0x1a9): undefined reference to `std::basic_streambuf<char, std::char_traits<char> >::_M_out_cur_move(long)'
color.o: In function `std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::seekpos(std::fpos<__mbstate_t>, std::_Ios_Openmode)':
color.cpp:(.gnu.linkonce.t._ZNSt15basic_stringbufIcSt11char_traitsIcESaIcEE7seekposESt4fposI11__mbstate_tESt13_Ios_Openmode+0x128): undefined reference to `std::basic_streambuf<char, std::char_traits<char> >::_M_out_cur_move(long)'
color.o: In function `std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::overflow(int)':
color.cpp:(.gnu.linkonce.t._ZNSt15basic_stringbufIcSt11char_traitsIcESaIcEE8overflowEi+0xd5): undefined reference to `std::basic_streambuf<char, std::char_traits<char> >::_M_out_cur_move(long)'
collect2: ld returned 1 exit status
make: *** [all] Error 1

I am using gcc version 4.02. "g++ -v -H" gives
Code:

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.0 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.2 (Debian 4.0.2-2)

Does anyone knows what's wrong? (the app compiled just fine on my old slackware 10.1)

Thanx

Tinkster 10-15-2005 08:49 PM

As far as I can see you just forgot to tell the compiler
where to find the library... there's no -L statment.


Cheers,
Tink

MasterOfTheWind 10-16-2005 05:32 AM

Well, I've tried that too. I've also tried to link the library directly, like
Code:

g++ /usr/lib/libstdc++-.so.5 main.o some_obj.o -o prog
And that of course didn't help either... so I'm rather clueless about what's really going on here :confused:

Tinkster 10-16-2005 12:16 PM

Code:

g++ -L/usr/lib -lstdc++ -lm -O3 -ffast-math -Wall -I. main.o utils.o vector.o color.o matrix.o transform.o shape.o sphere.o -o iray
should work...

Cheers,
Tink

MasterOfTheWind 10-16-2005 12:36 PM

well, thanks for your suggestion :) I tried it, but I am still not able to compile my raytracer on debian sid. I'm getting a new kind of output now, though:

Code:

g++ -L/usr/lib -lm -lstdc++ -O3 -ffast-math -Wall -I. main.o utils.o vector.o color.o matrix.o transform.o shape.o sphere.o -o ivanray
utils.o: In function `__gnu_cxx::__common_pool_base<__gnu_cxx::__pool, true>::_S_initialize()':
utils.cpp:(.gnu.linkonce.t._ZN9__gnu_cxx18__common_pool_baseINS_6__poolELb1EE13_S_initializeEv[__gnu_cxx::__common_pool_base<__gnu_cxx::__pool, true>::_S_initialize()]+0xd2): undefined reference to `__gnu_cxx::__pool<true>::_M_initialize()'
utils.o: In function `__gnu_cxx::__common_pool_base<__gnu_cxx::__pool, true>::_S_initialize_once()':
utils.cpp:(.gnu.linkonce.t._ZN9__gnu_cxx18__common_pool_baseINS_6__poolELb1EE18_S_initialize_onceEv[__gnu_cxx::__common_pool_base<__gnu_cxx::__pool, true>::_S_initialize_once()]+0x101): undefined reference to `__gnu_cxx::__pool<true>::_M_initialize()'
utils.o: In function `__gnu_cxx::__mt_alloc<NumValue, __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true> >::allocate(unsigned int, void const*)':
utils.cpp:(.gnu.linkonce.t._ZN9__gnu_cxx10__mt_allocI8NumValueNS_20__common_pool_policyINS_6__poolELb1EEEE8allocateEjPKv[__gnu_cxx::__mt_alloc<NumValue, __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true> >::allocate(unsigned int, void const*)]+0x2a1): undefined reference to `__gnu_cxx::__pool<true>::_M_initialize()'
collect2: ld returned 1 exit status
make: *** [all] Error 1

EDIT:
But now I noticed something strange: sometimes apt-get complains about a missing version of GLIBCXX when installing some deb-files:
Code:

update-menus: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.6' not found (required by update-menus)
I haven't seen that one before... so where is this reference pointing to? what kind of library should I install or re-install? libc? I thought that everything was updated all right... Shouldn't have switched to Debian :( My Slackware was fine enough. What do they say? Don't fix what ain't broken?

Harmaa Kettu 10-16-2005 12:51 PM

Looks like you have a version conflict. libstdc++.so.5 is for gcc 3.3 or older, gcc 3.4 and 4.0 use libstdc++.so.6

MasterOfTheWind 10-16-2005 01:23 PM

Oh yes, of course you are right! Compilation works with g++-3.3! Thanks a lot!

Though I still can't understand one thing: I have installed libstdc++ 5 and 6 while I also have g++ of versions 2.95, 3.3, 3.4 and 4.0. Don't ask how they ended up on my system, 'cause I can't recall installing them ;) (does debian install them by default or something?? but c'mon... 4 versions??). Well, anyway, it's all right that g++ 2.95 and 2.33 choose libstdc++ 5 instead of libstdc++ 6, but why do g++ 3.4 and 4.0 automatically use that same version (libstdc++ 5)? Is there any way to make them aware that the libstdc++ 6 is also installed?


All times are GMT -5. The time now is 04:15 PM.