AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
Expand all | Collapse all

g++-4.0.0 for aix5.3L and stdc++

  • 1.  g++-4.0.0 for aix5.3L and stdc++

    Posted Wed October 04, 2006 09:56 AM

    Originally posted by: SystemAdmin


    hi.
    Sorry for my inglish.
    I have few programs in c++ which i want to compile on AIX using g++ from your rpm database. I downloaded few rpms, they installed in /opt/freeware.
    At first: In one forum i read that library libstdc++.a contain libstdc++.so.6, so ar -d libstdc++.a, and i have dynamic library). It is right? Or i can use .a library?Plz tell me right way.

    I use
    /opt/freeware/bin/g++ -o proga ./*.cpp -L. -lpthread -lstdc++ to compile sources, but i see this:
    ld: 0711-317 ERROR: Undefined symbol: vtable for __cxxabiv1::__class_type_info
    ld: 0711-317 ERROR: Undefined symbol: vtable for __cxxabiv1::__si_class_type_info
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char>, std::allocator<char> >::capacity() const
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char>, std::allocator<char> >::empty() const
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char>, std::allocator<char> >::c_str() const
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned long) const

    and so on.
    if i use -lstdc++.a, compiles says "collect2: library libstdc++.a not found"? but i copy lib in my directory.
    Plz help me.
    #AIX-Forum


  • 2.  A few suggestions

    Posted Tue October 10, 2006 09:12 AM

    Originally posted by: nagger


    This is mostly a problem with the GNU compiler tools rather than AIX - I would look there for the answer to questions.

    I suggest you try compiling a hello world C++ program before you try something complex.

    Doesn't: ar -d libstdc++.a
    delete the library?

    Have you installed libstdc++-devel ?
    this is required for compilation and not libstdc++ which is required to execute programs.

    I assume the RPM database is http://www-03.ibm.com/servers/aix/products/aixos/linux/download.html
    right?

    I hope this helps and you can compile, N
    #AIX-Forum


  • 3.  Re: A few suggestions

    Posted Tue October 10, 2006 09:18 AM

    Originally posted by: SystemAdmin


    you are right) i extracted so library(sorry for mistake). Yes, I downloaded all rpms. I'll try next when server come back.
    thanks for help.
    #AIX-Forum


  • 4.  Re: A few suggestions

    Posted Thu October 12, 2006 11:52 AM

    Originally posted by: SystemAdmin


    I have same problem.
    I downloaded rpm's at 09/10/06.

    Currently compiling very simple program with string usage
    • code start --

    #include <string>
    using namespace std;
    int main()
    {
    std::string kk = "KK";
    printf("%S\n", kk.c_str());
    return 0;
    }

    • code end --

    • compilation process --
    1. g++ -o stltest stltest.cpp
    ld: 0711-317 ERROR: Undefined symbol: .std::allocator<char>::allocator()
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std
    ::allocator<char> const&)
    ld: 0711-317 ERROR: Undefined symbol: .std::allocator<char>::~allocator()
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char>, std::allocator<char> >::c_str() const
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()
    ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
    collect2: ld returned 8 exit status
    • compilation process end --

    ar -d etc doesn't delete the library.
    adding -L and -lstdc++ doesn't help.

    Thank you in advance.
    #AIX-Forum


  • 5.  Re: A few suggestions

    Posted Mon October 23, 2006 03:12 PM

    Originally posted by: SystemAdmin


    I am new to this mailing list, and using AIX again, after several years lapse.
    Please accept my gratitude in advance for your patience.

    Has a solution to this problem been posted?
    Where?

    I can compile but not link a program that uses streams.
    I have been able to compile and link programs that use printf().
    I have recently installed gcc-4.0.0 via rpm's from
    http://www-03.ibm.com/servers/aix/products/aixos/linux/download.html
    onto an
    AIX-5.3 box
    ksh> g++ --version
    g++ (GCC) 4.0.0
    ...

    I can compile a hello world program.
    ksh> cat hello.cc
    #include <iostream>

    int main(int argc, char *argv[]) {
    printf("Hello, world!\n");
    std::cout << "Hello, world!\n";
    }
    ksh> g++ -c hello.cc
    ksh> ls -l hello.o
    -rw-r--r-- 1 xxxxxxxx xxxxxxx 2528 Oct 23 14:42 hello.o

    I cannot link the hello world program.
    ksh> g++ -o hello hello.o
    ld: 0711-317 ERROR:
    Undefined symbol: .std::basic_ostream<char,std::char_traits<char> >&
    std::operator<< <std::char_traits<char>>
    (std::basic_ostream<char, std::char_traits<char> >&,
    char const*)
    ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
    collect2: ld returned 8 exit status

    I am not familiar with loadmap nor noquiet and do not know where to obtain them.
    As I suspect that these simply output the link addresses, I don't believe they
    would be of much aid in this case.
    I can confirm that the library contains the requisite symbol.
    ksh> nm hello.o | grep stream
    ._ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc U
    ksh> nm ~/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.0.0/libstdc++.a |
    > grep ._ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
    ._ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc T 269005440
    ._ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc t 269005440 964

    I understand that I can force inclusion of the library explicitly.,
    but I get the same error.
    ksh> g++ -o hello hello.o \
    > ~/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.0.0/libstdc++.a
    ld: 0711-317 ERROR:
    Undefined symbol: .std::basic_ostream<char,std::char_traits<char> >&
    std::operator<< <std::char_traits<char>>
    (std::basic_ostream<char, std::char_traits<char> >&,
    char const*)
    ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
    collect2: ld returned 8 exit status

    TIA,
    #AIX-Forum


  • 6.  Re: A few suggestions

    Posted Wed October 25, 2006 09:15 AM

    Originally posted by: SystemAdmin


    I haven't seen any clear solution.
    Problem still exists. If you find solution for gcc 4.0 please post it here.

    I found some bug with same descrition on gcc bug list for gcc 3.1 :
    There are same sympthoms when gcc compiled using gnu binutils.

    I think that package is broken: I taken elder gcc packages from

    ftp://ftp.software.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc/gcc/
    (3.3.2.5 version) and simple stl program successfully compiled.

    (I have another problems with my original code, but it looks much better)

    Best regards.
    #AIX-Forum


  • 7.  Re: A few suggestions (gcc.4.1.1 might work)

    Posted Thu October 26, 2006 04:08 PM

    Originally posted by: SystemAdmin


    Thank you all for your suggestions.

    I tried downloading from your suggested site,
    ftp://ftp.software.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc/gcc/
    but the rpm was the same as that posted by IBM, which failed.

    I tried downlading
    gcc.4.1.1.powerpc.aix5.tar.Z
    from http://www.gnu.org/software/gcc/...(?)
    and it can at least compile hello world.

    I'll report back to this forum topic if I encounter any major problems.


    #AIX-Forum


  • 8.  Re: A few suggestions (gcc.4.1.1 might work)

    Posted Thu January 11, 2007 12:45 PM

    Originally posted by: SystemAdmin


    I tried the IBM site's RPM package of gcc-4.0.0 and the latest gcc-4.1.1 from ftp.gnu.org with the same issues. C programs compile and run fine but C++ programs compiled with the current release of libstdc++ built from the gcc RPMS and/or the gnu package fail at the link stage when compiling LIBTFF-3.8.2 or GMP.
    Here is the final section of the build log:
    Making all in port
    make[1]: Entering directory `/opt/freeware/src/packages/BUILD/tiff-3.8.2/port'
    make[1]: Nothing to be done for `all'.
    make[1]: Leaving directory `/opt/freeware/src/packages/BUILD/tiff-3.8.2/port'
    Making all in libtiff
    make[1]: Entering directory `/opt/freeware/src/packages/BUILD/tiff-3.8.2/libtiff'
    /opt/freeware/bin/make all-am
    make[2]: Entering directory `/opt/freeware/src/packages/BUILD/tiff-3.8.2/libtiff'
    /bin/sh ../libtool --mode=link /opt/freeware/bin/g++ -g -O2 -o libtiffxx.la -rpath /opt/freeware/lib -no-undefined -version-number 3:8:2 tif_stream.lo ../libtiff/libtiff.la ../port/libport.la -ljpeg -lz -lm -lc
    libtool: link: rm -fr .libs/libtiffxx.exp
    libtool: link: generating symbol list for `libtiffxx.la'
    libtool: link: /bin/nm -BCpg .libs/tif_stream.o ../port/.libs/libport.a | awk '{ if ((($ 2 == "T") || ($ 2 == "D") || ($ 2 == "B")) && (substr($ 3,1,1) != ".")) { print $ 3 } }' | sort -u > .libs/libtiffxx.exp
    libtool: link: /opt/freeware/bin/g++ -shared -o .libs/libtiffxx.so.3 .libs/tif_stream.o ../port/.libs/libport.a -Wl,-blibpath:/usr/src/packages/BUILD/tiff-3.8.2/libtiff/.libs:/opt/freeware/lib:/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.1.1:/usr/lib/gcc/powerpc-ibm-aix5.3.0.0/4.1.1:/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.1.1/../../..:/usr/lib:/lib -L../libtiff/.libs -ltiff -ljpeg -lz -L/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.1.1 -L/usr/lib/gcc/powerpc-ibm-aix5.3.0.0/4.1.1 -L/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.1.1/../../.. -lstdc++ -lm -lc -lgcc_s -Wl,-bnoentry -Wl,-bE:.libs/libtiffxx.exp -Wl,-bernotok
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char> >::tellp()
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_istream<char, std::char_traits<char> >::tellg()
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_istream<char, std::char_traits<char> >::read(char*, long)
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char> >::write(char const*, long)
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char> >::seekp(long long, std::_Ios_Seekdir)
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char> >::seekp(std::fpos<char*>)
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_istream<char, std::char_traits<char> >::seekg(long long, std::_Ios_Seekdir)
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_istream<char, std::char_traits<char> >::seekg(std::fpos<char*>)
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char)
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)
    ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char> >::put(char)
    ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
    collect2: ld returned 8 exit status
    make[2]: *** http://libtiffxx.la Error 1
    make[2]: Leaving directory `/opt/freeware/src/packages/BUILD/tiff-3.8.2/libtiff'
    make[1]: *** all Error 2
    make[1]: Leaving directory `/opt/freeware/src/packages/BUILD/tiff-3.8.2/libtiff'
    make: *** all-recursive Error 1

    I am using the most current releases of the supporting toolsets, which successfully built with gcc 4.1.1.1 after a bit of tweaking:
    autoconf-2.59-5
    automake-1.9.5-1
    libtool-1.5.22.multilib2-3
    m4-1.4.8-1

    This is the configure command that I used with libtiff-3.8.2:
    ./configure --prefix=/opt/freeware --disable-largefile --enable-static --enable-shared --with-cc=/opt/freeware/bin/gcc --with-cxx=/opt/freeware/bin/g++ --with-ld=/bin/ld --with-ranlib=/bin/ranlib --with-make=/opt/freeware/bin/make --with-ar=/bin/ar --with-as=/bin/as --with-nm=/opt/freeware/bin/nm

    Having successfully built LIBTIFF-3.7.2 on AIX 5.0 using the then current gcc-2.95 RPMS for AIX, I learned that you must:
    1) Disable largefile as the macros used to define fseek for large files get undefined. Since AIX supports largefiles anyway, there is actually no loss
    of functionality
    2) use the AIX linker /bin/ld instead of the GNU linker at least for past versions of gnu ld
    3) only a current version of GNU nm seems to be able to properly handle the weak symbols in libstdc++ correctly. Using the -C flag to demangle the symbols shows that only the wchar_t versions of the symbols are present, the regular <char> char_traits types are missing. Running the same command on the version of libstdc++.so reveals the missing symbols ARE present there and of course LIBTIFF builds correctly in that environment.

    /opt/freeware/bin/nm -C libstdc++.a | grep seekg
    0000000010076730 t .std::istream::seekg(std::fpos<char*>)
    0000000010076730 W .std::istream::seekg(std::fpos<char*>)
    00000000100765d0 W .std::istream::seekg(long long, std::_Ios_Seekdir)
    00000000100765d0 t .std::istream::seekg(long long, std::_Ios_Seekdir)
    0000000010076b9c t .std::basic_istream<wchar_t, std::char_traits<wchar_t> >::seekg(std::fpos<char*>)
    0000000010076b9c W .std::basic_istream<wchar_t, std::char_traits<wchar_t> >::seekg(std::fpos<char*>)
    0000000010076a18 W .std::basic_istream<wchar_t, std::char_traits<wchar_t> >::seekg(long long, std::_Ios_Seekdir)
    0000000010076a18 t .std::basic_istream<wchar_t, std::char_traits<wchar_t> >::seekg(long long, std::_Ios_Seekdir)

    I've posted to LIBTIFF's bugzilla, but this is not really a LIBTIFF issue. It also occurs with GMP on AIX. I think that it has to do with the LIBTOOL build mechanism's code to export symbols or the LIBCXXFLAGS="-O2 -fno-implicit-templates" flag in the IBM gcc-4.0.0.0 spec file. I've built with and without this flag with the same result. Since the symbols don't show up in libstdc++ on AIX, I'd have to blame the gcc build mechanism, but I can't track it down.
    #AIX-Forum


  • 9.  Re: A few suggestions (gcc.4.1.1 might work)

    Posted Fri March 02, 2007 08:18 AM

    Originally posted by: SystemAdmin


    I have the same question, is there a answer?
    #AIX-Forum


  • 10.  Re: A few suggestions (gcc.4.1.1 might work)

    Posted Fri March 02, 2007 09:01 AM

    Originally posted by: SystemAdmin


    > I have the same question, is there a answer?

    There is a workaround.
    See "How to use libstdc++ on aix-5.3 with files >2G"
    in this same forum.

    Limitations of this workaround:
    o shard libraries are either unsupported,
    or require further unknown configuration settings
    o linking c++ with c libraries sometimes fails
    with report of undefined global symtols, crypt_r ...
    referenced by libc.ahttp://shr64.o

    Hopefully helpful,
    #AIX-Forum


  • 11.  Re: A few suggestions (gcc.4.1.1 might work)

    Posted Fri March 02, 2007 11:30 PM

    Originally posted by: SystemAdmin


    Here is what I have found after having tried all the RPMs from the IBM site since the 2.9.5 release.

    Gcc 3x or even 4.0 or 4.1 work fine if you use the AIX versions of ld, nm, ranlib, ar, dump, etc, everything but gcc itself.

    G++ works fine but the libstdc++ is borked, missing a huge number of entries. Building libstdc++ with any version of gcc based on the new IBM distributed RPMS fails as well. You get a library with missing symbols. The issue seems to be that when buildng the second and third stage versions of the compiler with the just built first stage compiler the build script uses the binutils that it builds in the package which have not worked on AIX for years. We had a consultant who is an expert at these things hand build us a version of GCC 4.1.1 starting with the UCLA pdslib version but compiling it with the older 2.9.5 release for the first stage if I remember correctly.

    Now I have built libtiff, Hylafax, and other programs with G++ 4.1.1 on AIX 5.3 ML 5 with the 64 bit kernel successfully The new libstdc++ is over three times as large as the one in the RPM distributed on the IBM freeware site. Part of this must have to do with the missing symbols and part of it with not using delayed linking in the library itself. You have to use -blibpath and -bnoipath to make the installed library usable once you move it from where you build it to where you install it. I haven't had the time to figure out exactly what he did, but I am sure he modifed the way the second and third stage builds find the tools. A complete build takes 4 days on an unloaded H80 or two days on a P650 with faster disks.
    #AIX-Forum


  • 12.  Re: A few suggestions (gcc.4.1.1 might work)

    Posted Mon March 05, 2007 01:27 AM

    Originally posted by: SystemAdmin


    Mr || Mrs rnolde:

    Thanks for your advice.
    The sloution looks too complex to me, and too risky to my project. I am asking Hardware maker and aixtoolbox team for help.

    thanks again.
    #AIX-Forum


  • 13.  Re: A few suggestions (gcc.4.1.1 might work)

    Posted Mon March 05, 2007 09:37 AM

    Originally posted by: SystemAdmin


    Thank you for your research.

    > Here is what I have found after having tried all the
    > RPMs from the IBM site since the 2.9.5 release.
    >
    > Gcc 3x or even 4.0 or 4.1 work fine if you use the
    > AIX versions of ld, nm, ranlib, ar, dump, etc,
    > everything but gcc itself.
    >
    > http://libstdc++ is borked, ...
    >
    > Now I have built libtiff, Hylafax, and other programs
    > with G++ 4.1.1 on AIX 5.3 ML 5 with the 64 bit kernel
    > successfully.

    My congratulations to your 'hired expert'.

    Could you post the updated rpms?
    gcc-4.1.1.src.aix53.ppc.rpm?
    libstdc++-4.1.1.src.aix53.ppc.rpm?
    gcc-c++-4.1.1.aix53.ppc.rpm?
    gcc-4.1.1.aix53.ppc.rpm?
    libstc++-4.1.1.aix53.ppc.rpm?
    ...
    TIA,
    #AIX-Forum


  • 14.  Re: a workaround

    Posted Mon March 05, 2007 01:06 AM

    Originally posted by: SystemAdmin


    Mr/Mrs DrB:

    Thanks for your advice. I compile my hello world successfully by add -static to command line.

    Ref:
    http://www-128.ibm.com/developerworks/forums/dw_thread.jsp?message=13925965&cat=72&thread=153470&treeDisplayType=threadmode1&forum=747#13925965
    #AIX-Forum


  • 15.  Re: g++-4.0.0 for aix5.3L and stdc++

    Posted Fri November 16, 2007 10:15 AM

    Originally posted by: capeme


    So did anyone ever find a fix for this??Can I install differentt libraries or version of gcc or????
    #AIX-Forum


  • 16.  Re: g++-4.0.0 for aix5.3L and stdc++

    Posted Sat December 08, 2007 11:32 AM

    Originally posted by: SystemAdmin


    Sorry for coming to this one so late in the game. Both capeme and DrB asked about a resolution and I could find no replies to those requests.
    As far as I can tell, a year later there is still no later version of gcc-c++ than gcc-c++-4.0.0-1 that I can find. Same for libstdc++-4.0.0-1. I'm new to aix and am wondering if anyone found a solution, other than the workaround posted by DrB, like the rpms asked for by DrB.

    TIA for whatever anyone can tell me.
    #AIX-Forum


  • 17.  Re: g++-4.0.0 for aix5.3L and stdc++

    Posted Mon February 18, 2008 11:14 AM

    Originally posted by: tvheros2


    Use -G option with ld or Wl,-G if you invoke the linker with g++
    You don't need to add -lstdc++ to you link options.
    This will make the compilation OK.
    If you test your program with ldd you won't have resolution problem.

    BUT

    If I use std::string I get an execution error on the constructor of std::string (exactly on the std::allocator<char>).

    And I can't get a solution at this point.
    #AIX-Forum


  • 18.  Re: g++-4.0.0 for aix5.3L and stdc++

    Posted Wed March 26, 2008 02:47 AM

    Originally posted by: bocheff


    Try to use version of gcc and g++ from this link http://pware.hvcc.edu/downloads.html
    #AIX-Forum