Archived

This forum has been archived. Please start a new discussion on GitHub.

Compilation error

I'm using RedHat 7.2 and gcc 3.2; I'm compiling version 1.0.1
Both shared libraries libIceUtil.so and libSlice compiles and links well, but later slice2cpp doesn't. Any ideas? Here are the make output:

make[2]: Entering directory `/home/ax10077/Ice-1.0.1/src/IceUtil'
c++ -c -I../../include -g -ftemplate-depth-128 -fPIC -Wall Exception.cpp
c++ -c -I../../include -g -ftemplate-depth-128 -fPIC -Wall Unicode.cpp
c++ -c -I../../include -g -ftemplate-depth-128 -fPIC -Wall UUID.cpp
c++ -c -I../../include -g -ftemplate-depth-128 -fPIC -Wall RecMutex.cpp
c++ -c -I../../include -g -ftemplate-depth-128 -fPIC -Wall RWRecMutex.cpp
c++ -c -I../../include -g -ftemplate-depth-128 -fPIC -Wall Cond.cpp
c++ -c -I../../include -g -ftemplate-depth-128 -fPIC -Wall Thread.cpp
c++ -c -I../../include -g -ftemplate-depth-128 -fPIC -Wall ThreadException.cpp
c++ -c -I../../include -g -ftemplate-depth-128 -fPIC -Wall Time.cpp
c++ -c -I../../include -g -ftemplate-depth-128 -fPIC -Wall InputUtil.cpp
c++ -c -I../../include -g -ftemplate-depth-128 -fPIC -Wall OutputUtil.cpp
c++ -c -I../../include -g -ftemplate-depth-128 -fPIC -Wall Base64.cpp
rm -f ../../lib/libIceUtil.so.1.0.1
c++ -shared -Xlinker -soname -Xlinker libIceUtil.so.1.0.1 -L../../lib -o ../../lib/libIceUtil.so.1.0.1 Exception.o Unicode.o UUID.o RecMutex.o RWRecMutex.o Cond.o Thread.o ThreadException.o Time.o InputUtil.o OutputUtil.o Base64.o
rm -f ../../lib/libIceUtil.so
ln -s libIceUtil.so.1.0.1 ../../lib/libIceUtil.so
make[2]: Leaving directory `/home/ax10077/Ice-1.0.1/src/IceUtil'

make[2]: Entering directory `/home/ax10077/Ice-1.0.1/src/Slice'
c++ -c -I.. -I../../include -g -ftemplate-depth-128 -fPIC -Wall Scanner.cpp
c++ -c -I.. -I../../include -g -ftemplate-depth-128 -fPIC -Wall Grammar.cpp
c++ -c -I.. -I../../include -g -ftemplate-depth-128 -fPIC -Wall Parser.cpp
c++ -c -I.. -I../../include -g -ftemplate-depth-128 -fPIC -Wall CPlusPlusUtil.cpp
c++ -c -I.. -I../../include -g -ftemplate-depth-128 -fPIC -Wall JavaUtil.cpp
c++ -c -I.. -I../../include -g -ftemplate-depth-128 -fPIC -Wall Preprocessor.cpp
rm -f ../../lib/libSlice.so.1.0.1
c++ -shared -Xlinker -soname -Xlinker libSlice.so.1.0.1 -L../../lib -o ../../lib/libSlice.so.1.0.1 Scanner.o Grammar.o Parser.o CPlusPlusUtil.o JavaUtil.o Preprocessor.o
rm -f ../../lib/libSlice.so
ln -s libSlice.so.1.0.1 ../../lib/libSlice.so
make[2]: Leaving directory `/home/ax10077/Ice-1.0.1/src/Slice'

make[2]: Entering directory `/home/ax10077/Ice-1.0.1/src/slice2cpp'
c++ -c -I. -I../../include -g -ftemplate-depth-128 -fPIC -Wall Gen.cpp
c++ -c -I. -I../../include -g -ftemplate-depth-128 -fPIC -Wall Main.cpp
rm -f ../../bin/slice2cpp
c++ -L../../lib -o ../../bin/slice2cpp Gen.o Main.o -lSlice -lIceUtil -lpthread -luuid
../../lib/libIceUtil.so: undefined reference to `std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::operator[](unsigned) const'
../../lib/libIceUtil.so: undefined reference to `std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::~basic_string [in-charge]()'
../../lib/libIceUtil.so: undefined reference to `std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::length() const'
../../lib/libIceUtil.so: undefined reference to `std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::operator+=(wchar_t)'
../../lib/libIceUtil.so: undefined reference to `std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::reserve(unsigned)'
../../lib/libIceUtil.so: undefined reference to `std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::basic_string[in-charge]()'
collect2: ld returned 1 exit status

thanks in advance. Diego.

Comments

  • benoit
    benoit Rennes, France
    Hi Diego,

    It looks a lot like the error you would get if you use the STL library from gcc 2.96.x (which doesn't have support for std::wstring). Can you make sure you're using the right compiler?

    You should be able to check for the STL C++ library with:

    c++ -print-file-name=libstdc++.so

    This should print the path of the STL library which will be used to link your program with.

    Benoit.
  • Thanks Benoi

    Here is the requested command:

    c++ -print-file-name=libstdc++.so
    /usr/lib/gcc-lib/i386-redhat-linux/3.2/libstdc++.so

    It's gcc 3.2 version. Any other idea?

    Best regards. Diego.
  • mes
    mes California
    If I were having this problem, I'd probably try poking around in the library to see if these symbols are present. For example:

    nm -C /usr/lib/gcc-lib/i386-redhat-linux/3.2/libstdc++.so | grep 'basic_string.*wchar' | more

    Another option would be to build GCC yourself.

    Finally, you can disable the compilation of src/IceUtil/Unicode.cpp. This file contains utility functions that are not used by the rest of the Ice distribution.

    - Mark
  • Solved

    The problem was that my gcc version doesn't support Unicode. I removed Unicode from libIceUtil, and now it links ok.
    Thanks a lot. Diego.