Linker paths and libstdc++ errors

Sean Callanan sc843@bard.edu
Tue Dec 18 11:54:00 GMT 2001


Dear mailing list:

I have a sparc64 system on which I am building a chroot with 32- and 64-bit 
libraries and binaries.

The following are configure commands for my toolchains (they run inside the 
chroot):

[32-bit binutils] ../binutils-2.11.2/configure --prefix=/usr 
--program-prefix=sparc-linux- --enable-shared --host=sparc-linux
[64-bit binutils] ../binutils-2.11.2/configure --prefix=/usr 
--program-prefix=sparc64-linux- --enable-shared --host=sparc-linux 
--target=sparc64-linux --libdir=/usr/lib64
[32-bit gcc] ../gcc-3.0.2/configure --prefix=/usr 
--program-prefix=sparc-linux- --enable-languages=c,c++,objc,java 
--enable-threads=posix --host=sparc-linux
[64-bit gcc] ../gcc-3.0.2/configure --prefix=/usr 
--program-prefix=sparc64-linux- --enable-languages=c --disable-threads 
--enable-shared --host=sparc-linux --target=sparc64-linux --libdir=/usr/lib64
[32-bit glibc] ../glibc-2.2.4/configure --prefix=/usr 
--disable-sanity-checks --enable-add-ons --program-prefix=sparc-linux- 
--libexecdir=/usr/bin --host=sparc-linux
[64-bit glibc] ../glibc-2.2.4/configure --prefix=/usr 
--disable-sanity-checks --enable-add-ons --program-prefix=sparc64-linux- 
--libexecdir=/usr/bin --libdir=/usr/lib64 --host=sparc64-linux

I am able to compile 32-bit C programs and run them without difficulty. The 
same goes for 32-bit C++ programs. I am also able to execute 
/lib64/ld-linux.so.2 and /lib64/libc.so.6.  However, the following problems 
occur on 64-bit compilation:
--
#cat test.c

#include <stdio.h>

void main()
{
   printf("Hello world!\n");
}

#sparc64-linux-gcc -v -o test test.c

[...preprocessor and assembler messages...]
  /usr/lib64/gcc-lib/sparc64-linux/3.0.2/collect2 -m elf64_sparc -Y 
P,/usr/lib64 -dynamic-linker /lib64/ld-linux.so.2 -relax -o test 
/usr/lib64/crt1.o /usr/lib64/crti.o 
/usr/lib64/gcc-lib/sparc64-linux/3.0.2/crtbegin.o 
-L/usr/lib64/gcc-lib/sparc64-linux/3.0.2 
-L/usr/lib64/gcc-lib/sparc64-linux/3.0.2/../../../../sparc64-linux/lib 
/tmp/cckf8v1e.o -lgcc -lc -lgcc 
/usr/lib64/gcc-lib/sparc64-linux/3.0.2/crtend.o /usr/lib64/crtn.o
/usr/lib64/gcc-lib/sparc64-linux/3.0.2/../../../../sparc64-linux/bin/ld: 
warning: ld-linux.so.2, needed by /lib64/libc.so.6, not found (try using 
-rpath or -rpath-link)
/lib64/libc.so.6: undefined reference to `_dl_loaded@GLIBC_2.2'
/lib64/libc.so.6: undefined reference to `_dl_map_object@GLIBC_2.2'
[...many more undefined references...]
collect2: ld returned 1 exit status

#sparc64-linux-gcc -o test test.c -Xlinker -rpath-link=/lib64:/usr/lib64
--
Now the compiler will compile the test program properly. So my question is: 
how do I set this to be permanent? I'd ideally like to bootstrap a 64-bit 
native compiler but until this issue gets sorted out I won't be 
bootstrapping anything...

This is the first problem. Now for the second: C++ programs under sparc64 
won't compile at all:
--
#cat test.cc

#include <iostream.h>

int main()
{
   cout << "Hello world!" << endl;
   return(0);
}

#sparc64-linux-g++ -o test-c++ test.cc

In file included from /usr/include/g++-v3/backward/iostream.h:32,
                  from test.cc:1:
/usr/include/g++-v3/bits/std_iostream.h:39:28: bits/c++config.h: No such 
file or directory
In file included from /usr/include/g++-v3/bits/std_ios.h:39,
                  from /usr/include/g++-v3/bits/std_ostream.h:39,
                  from /usr/include/g++-v3/bits/std_iostream.h:40,
                  from /usr/include/g++-v3/backward/iostream.h:32,
                  from test.cc:1:
/usr/include/g++-v3/bits/std_iosfwd.h:39:28: bits/c++config.h: Success
[...more like this...]
In file included from /usr/include/g++-v3/bits/std_memory.h:50,
                  from /usr/include/g++-v3/bits/std_string.h:43,
                  from /usr/include/g++-v3/bits/localefwd.h:42,
                  from /usr/include/g++-v3/bits/std_ios.h:43,
                  from /usr/include/g++-v3/bits/std_ostream.h:39,
                  from /usr/include/g++-v3/bits/std_iostream.h:40,
                  from /usr/include/g++-v3/backward/iostream.h:32,
                  from test.cc:1:
/usr/include/g++-v3/bits/stl_alloc.h: At global scope:
/usr/include/g++-v3/bits/stl_alloc.h:288: parse error before `[' token
/usr/include/g++-v3/bits/stl_alloc.h: In static member function `static 
void* std::__default_alloc_template<threads, inst>::allocate(long unsigned int)':
/usr/include/g++-v3/bits/stl_alloc.h:331: parse error before `;' token
/usr/include/g++-v3/bits/stl_alloc.h: In static member function `static 
void std::__default_alloc_template<threads, inst>::deallocate(void*, long 
unsigned int)':
/usr/include/g++-v3/bits/stl_alloc.h:358: parse error before `;' token
/usr/include/g++-v3/bits/stl_alloc.h: In static member function `static 
char* std::__default_alloc_template<threads, inst>::_S_chunk_alloc(long 
unsigned int, int&)':
/usr/include/g++-v3/bits/stl_alloc.h:424: parse error before `*' token
/usr/include/g++-v3/bits/stl_alloc.h:433: parse error before `*' token
/usr/include/g++-v3/bits/stl_alloc.h: In static member function `static 
void* std::__default_alloc_template<threads, inst>::_S_refill(long unsigned 
int)':
/usr/include/g++-v3/bits/stl_alloc.h:474: parse error before `*' token
/usr/include/g++-v3/bits/stl_alloc.h: At global scope:
/usr/include/g++-v3/bits/stl_alloc.h:538: syntax error before `<' token
/usr/include/g++-v3/bits/stl_alloc.h:538: `__threads' was not declared in 
this scope
/usr/include/g++-v3/bits/stl_alloc.h:538: `__inst' was not declared in this scope
/usr/include/g++-v3/bits/stl_alloc.h:538: template argument 1 is invalid
/usr/include/g++-v3/bits/stl_alloc.h:538: template argument 2 is invalid
/usr/include/g++-v3/bits/stl_alloc.h:539: `__threads' was not declared in 
this scope
/usr/include/g++-v3/bits/stl_alloc.h:539: `__inst' was not declared in this scope
/usr/include/g++-v3/bits/stl_alloc.h:539: template argument 1 is invalid
/usr/include/g++-v3/bits/stl_alloc.h:539: template argument 2 is invalid
/usr/include/g++-v3/bits/stl_alloc.h:540: `::_NFREELISTS' undeclared (first 
use here)
/usr/include/g++-v3/bits/stl_alloc.h:540: assignment (not initialization) 
in declaration
/usr/include/g++-v3/bits/stl_alloc.h:571: parse error in method 
specification before `{' token
/usr/include/g++-v3/bits/stl_alloc.h:571: parse error before `}' token
/usr/include/g++-v3/bits/stl_alloc.h:572: missing ';' before right brace
/usr/include/g++-v3/bits/stl_alloc.h:573: semicolon missing after 
declaration of `std::allocator<_Alloc>'
/usr/include/g++-v3/bits/stl_alloc.h:571: parse error at end of saved 
function text
/usr/include/g++-v3/bits/stl_alloc.h:573: confused by earlier errors, bailing out
--
This is a more perplexing problem, but solving this one has as prerequisite 
the solution of the first.

As far as my ideas go, I've tried passing a number of additional parameters 
to configure (the --libdir=/lib64 for 64-bit programs, for example) when I 
compile binutils and gcc, to fix the library problem. I've also rooted 
around in the ldscripts for sparc64-linux-ld, adding SEARCH_DIR entries for 
/lib64, /usr/lib64, and /usr/local/lib64. I have the feeling there's some 
small detail about the parameters passed to configure that I'm missing.

When I've got these problems sorted out, I'm going to write a HOWTO about 
it. I realize I'm asking a lot of questions on this mailing list; please 
accept my sincere gratitude for all your help.

Sincerely,

Sean Callanan 



More information about the Gcc mailing list