public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Jonathan Saxton" <jsaxton@appsecinc.com>
To: <gcc-help@gcc.gnu.org>
Subject: [SOLVED]  Linking problems with gcc 4.2.2 and AIX 5.2
Date: Tue, 26 Feb 2008 03:08:00 -0000	[thread overview]
Message-ID: <001801c877c1$419f1fc0$381110ac@nycapt35k.com> (raw)
In-Reply-To: <009401c85f9f$1c2191e0$381110ac@nycapt35k.com>

Problem turned out to be traces of a binutils installation.  Merely
specifying options such as 
	--with-as=/usr/linux/bin/as \
	--without-gnu-ld \
    	--with-ld=/usr/bin/ld
during the configuration was NOT sufficient.  The configuration tool would
drill down through the installation directory (--prefix=whatever), find the
gnu versions of as and ld and build the (stage 3) compiler to use them.

The trick was to seek and destroy all traces of the gnu versions of these
programs and to rebuild the compiler from scratch.  (A stage 3 build didn't
work.)  With the gnu programs gone, none of the options listed above was
necessary.

Moral of the story:  On AIX 5.x don't try to generate a g++ compiler if you
have binutils installed.



-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Jonathan Saxton
Sent: 25 January, 2008 17:11
To: gcc-help@gcc.gnu.org
Subject: Linking problems with gcc 4.2.2 and AIX 5.2

A newbie gcc builder here.

I’ve found reports of similar problems from a year or so back but no real
resolution so I have to ask again.

Recently I used gcc 4.0.0 to compile gcc 4.2.2 on AIX 5.2.  Compiler seems
to work fine until I go to link something, then I get some fairly basic STL
things unresolved.  My test program is taken from the introductory chapters
of C++ Template Metaprogramming by Abrahams & Gurtovoy.

#include <iostream>

template <unsigned long N>
struct binary
{
    static unsigned const long value =
        binary<N/10>::value * 2 + N%10;
};

template <>
struct binary<0>
{
    static unsigned const long value = 0L;
};

int main()
{
    std::cout
       << "The answer to the question of Life, the Universe and Everything
is "
       << binary<101010>::value
       << std::endl;
}

The command “g++ -o demo422 demo422.cpp” yields six link errors:

$ g++ -o demo422 demo422.cpp
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> >::operator[](unsigned long)
const
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-317 ERROR: Undefined symbol: .std::basic_ostream<char,
std::char_traits<char> >::operator<<(unsigned long)
ld: 0711-317 ERROR: Undefined symbol: std::basic_ostream<char,
std::char_traits<char> >& std::endl<char, std::char_traits<char>
>(std::basic_ostream<char, std::char_traits<char> >&)
ld: 0711-317 ERROR: Undefined symbol: .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> >&))
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.
collect2: ld returned 8 exit status

Adding –Wl,-bnoquiet doesn’t really give anything that seems particularly
helpful (well, to me, anyway) but using the –v flag suggests that the
correct libstdc++.a is being found and also shows the (rather minimal) way I
configured gcc 4.2.2 when I built it.

$ g++ -v -o demo422 demo422.cpp
Using built-in specs.
Target: powerpc-ibm-aix5.2.0.0
Configured with: /home.local/jsaxton/gcc-4.2.2/configure
--prefix=/opt/freeware : (reconfigured)
/home.local/jsaxton/gcc-4.2.2/configure --prefix=/opt/freeware
--enable-languages=c,c++
Thread model: aix
gcc version 4.2.2
 /opt/freeware/libexec/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/cc1plus -quiet -v
-D_ALL_SOURCE demo422.cpp -quiet -dumpbase demo422.cpp -auxbase demo422
-version -o /tmp//ccPpunCt.s
ignoring nonexistent directory
"/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/../../../../powerpc-ibm-
aix5.2.0.0/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/../../../../include/c++/
4.2.2
 /opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/../../../../include/c++/
4.2.2/powerpc-ibm-aix5.2.0.0
 /opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/../../../../include/c++/
4.2.2/backward
 /usr/local/include
 /opt/freeware/include
 /opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/include
 /usr/include
End of search list.
GNU C++ version 4.2.2 (powerpc-ibm-aix5.2.0.0)
        compiled by GNU C version 4.2.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=32768
Compiler executable checksum: 757566dd4c47f91799c975df3ba00055
 as -u -mppc -o /tmp//ccRMMUUA.o /tmp//ccPpunCt.s
 /opt/freeware/libexec/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/collect2
-bpT:0x10000000 -bpD:0x20000000 -btextro -bnodelcsect -o demo422 /lib/crt0.o
-L/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2
-L/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/../../..
/tmp//ccRMMUUA.o -lstdc++ -lm -lgcc_s
/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/libgcc.a -lc -lgcc_s
/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/libgcc.a

(At this point the error messages shown earlier are displayed so I didn’t
bother to include them again.)

If my double-dot counting is correct, the library path devolves to
/opt/freeware/lib and there are four libstc++.a files thereunder, all
freshly created by the install.  I cannot see any trace of any library left
over from 4.0.0.

2008-01-25 16:15:01 nextferry:/opt/freeware/lib
$ find . -name libstdc++.a
./pthread/ppc64/libstdc++.a
./pthread/libstdc++.a
./ppc64/libstdc++.a
./libstdc++.a

I’m a bit stuck.

If I really need to rebuild gcc with different configuration options then
with a bit of work I can do that.  Meanwhile “which ld”  yields /usr/lbin/ld
which is a symlink to the native AIX linker (/usr/ccs/buin/ld).  There is no
gcc version of ld anywhere.  It is my understanding that this is correct for
AIX 5.x.

Advice eagerly sought.  I can generate the –bnoquiet output if needed but
this is already a very long message.


      parent reply	other threads:[~2008-02-25 15:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-26  9:21 Jonathan Saxton
2008-01-28 22:38 ` Thomas Mittelstaedt
2008-01-28 23:44   ` Jonathan Saxton
2008-02-01 22:31     ` Jonathan Saxton
2008-02-26  3:08 ` Jonathan Saxton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001801c877c1$419f1fc0$381110ac@nycapt35k.com' \
    --to=jsaxton@appsecinc.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).