g++ linking problem...


 
Thread Tools Search this Thread
Operating Systems Solaris g++ linking problem...
# 1  
Old 06-12-2009
g++ linking problem...

I use Solaris 10, compiling with a custom g++ (3.4.6) and GNU binutils (2.17). Things have gone well on two different systems, but when I tried moving to a third, it all fell over. Basically, it is now using the CC linker, but I need to use options not available to it. I believe I have found the root of the problem, but I do not understand what could cause this, or how best to fix it.

From a system that works:
Code:
$ which g++ ; g++ -v ; g++ -print-search-dirs | grep '^program'
/usr/local/bin/g++
Reading specs from /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/specs
Configured with: ./configure --with-gnu-ld
Thread model: posix
gcc version 3.4.6
programs: =/usr/local/libexec/gcc/sparc-sun-solaris2.10/3.4.6/:/usr/local
/libexec/gcc/sparc-sun-solaris2.10/3.4.6/:/usr/local/libexec/gcc/sparc-
sun-solaris2.10/:/usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/:/usr/local
/lib/gcc/sparc-sun-solaris2.10/:/usr/libexec/gcc/sparc-sun-solaris2.10/3.4.6
/:/usr/libexec/gcc/sparc-sun-solaris2.10/:/usr/lib/gcc/sparc-sun-solaris2.10
/3.4.6/:/usr/lib/gcc/sparc-sun-solaris2.10/:/usr/local/lib/gcc/sparc-
sun-solaris2.10/3.4.6/../../../../sparc-sun-solaris2.10/bin/sparc-
sun-solaris2.10/3.4.6/:/usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/../../../..
/sparc-sun-solaris2.10/bin/:/usr/ccs/bin/sparc-sun-solaris2.10/3.4.6/:/usr
/ccs/bin/
$ ls -l /usr/local/libexec/gcc/sparc-sun-solaris2.10/3.4.6/
total 39734
lrwxrwxrwx   1 bin      bin           39 Nov 20  2008 as -> /usr/local/sparc-sun-solaris2.10/bin/as
-rwxr-xr-x   1 bin      bin      6175052 Sep  5  2006 cc1
-rwxr-xr-x   1 bin      bin      7182392 Sep  5  2006 cc1plus
-rwxr-xr-x   1 bin      bin       329698 Nov 20  2008 collect2
-rwxr-xr-x   1 bin      bin      6609028 Sep  5  2006 f771
drwxr-xr-x   2 bin      bin          512 Nov 17  2008 install-tools
lrwxrwxrwx   1 bin      bin           39 Nov 20  2008 real-ld -> /usr/local/sparc-sun-solaris2.10/bin/ld

On the system that does not work:
Code:
$ which g++ ; g++ -v ; g++ -print-search-dirs | grep '^program'
/usr/local/bin/g++
Reading specs from /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/specs
Configured with: ./configure --with-gnu-ld
Thread model: posix
gcc version 3.4.6
programs: =/usr/sfw/sparc-sun-solaris2.10/../../libexec/gcc/sparc-
sun-solaris2.10/3.4.6/:/usr/sfw/sparc-sun-solaris2.10/../../libexec/gcc/:
/usr/sfw/sparc-sun-solaris2.10/bin/sparc-sun-solaris2.10/3.4.6/:/usr
/sfw/sparc-sun-solaris2.10/bin/:/usr/local/libexec/gcc/sparc-sun-solaris2.10
/3.4.6/:/usr/local/libexec/gcc/sparc-sun-solaris2.10/3.4.6/:/usr/local/libexec
/gcc/sparc-sun-solaris2.10/:/usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6
/:/usr/local/lib/gcc/sparc-sun-solaris2.10/:/usr/libexec/gcc/sparc-
sun-solaris2.10/3.4.6/:/usr/libexec/gcc/sparc-sun-solaris2.10/:/usr/lib/gcc
/sparc-sun-solaris2.10/3.4.6/:/usr/lib/gcc/sparc-sun-solaris2.10/:/usr
/sfw/sparc-sun-solaris2.10/bin/../../sparc-sun-solaris2.10/bin/sparc-
sun-solaris2.10/3.4.6/:/usr/sfw/sparc-sun-solaris2.10/bin/../../sparc-
sun-solaris2.10/bin/:/usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/../../../..
/sparc-sun-solaris2.10/bin/sparc-sun-solaris2.10/3.4.6/:/usr/local/lib/gcc
/sparc-sun-solaris2.10/3.4.6/../../../../sparc-sun-solaris2.10/bin/:/usr/ccs
/bin/sparc-sun-solaris2.10/3.4.6/:/usr/ccs/bin/
$ ls -l /usr/local/libexec/gcc/sparc-sun-solaris2.10/3.4.6/
total 39985
lrwxrwxrwx   1 root     root          37 Jun 11 10:36 as -> /usr/sfw/sparc-sun-solaris2.10/bin/as
-rwxr-xr-x   1 bin      bin      6175052 Sep  4  2006 cc1
-rwxr-xr-x   1 bin      bin      7182392 Sep  4  2006 cc1plus
-rwxr-xr-x   1 bin      bin       227256 Sep  4  2006 collect2
-rwxr-xr-x   1 bin      bin      6609028 Sep  4  2006 f771
drwxr-xr-x   2 bin      bin            5 May 14 11:24 install-tools
lrwxrwxrwx   1 root     root          37 Jun 11 10:36 real-ld -> /usr/sfw/sparc-sun-solaris2.10/bin/ld

The contents of /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/specs are identical between the two, and all the packages and package details (pkginfo) appear to be identical. The critical difference is that, in the system that is not working, the program search dirs are `wrong'. Even though it is a copy of the same g++, it seems as though some `prefix' is different between the two environments: on the system that works, it checks /usr/local/libexec/gcc/sparc-sun-solaris2.10/3.4.6/, whereas the other checks /usr/sfw/sparc-sun-solaris2.10/../../libexec/gcc/sparc-sun-solaris2.10/3.4.6/.

What could cause this difference, and what is the best resolution to this issue?

EDIT: I forgot to mention, I have tried the -B option with g++, as well as GCC_EXEC_PREFIX and COMPILER_PATH, with no success.

Last edited by Elric of Grans; 06-12-2009 at 12:37 AM.. Reason: Additional information.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. SuSE

Problem compiling the kernel and linking problems in OpenSuse 12.3

Hi everyone I installed OpenSuse 12.3 and many development tools but when i propose build the kernel from the source (the first step make menuconfig) i saw this: HOSTLD scripts/kconfig/mconf /usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: warning: libdl.so.2,... (2 Replies)
Discussion started by: bacesado
2 Replies

2. Programming

Linking problem

Hi! We recently updated the server (server is a big word, it's really just a desktop with Ubuntu that we access with ssh) on which we compile our code. Since the update my code won't compile. The linker is complaining about missing references from almost all .so that I'm linking from. It... (0 Replies)
Discussion started by: philippevk
0 Replies

3. Shell Programming and Scripting

Please help on tuxedo linking problem

Dear Unixians, I have try to link my libraries with tuxedo that showing following errors, ] My make file few lines: .... actual linking Please help on this. Thanks,KKL. (1 Reply)
Discussion started by: kkl
1 Replies

4. UNIX for Dummies Questions & Answers

is linking possible?

how would i link 2 files together? is it the same as copying? (1 Reply)
Discussion started by: trob
1 Replies

5. AIX

linking problem

hello, Is the code compiled under Visual Age C++ Broker (a third party library) - can be used to link against a code compiled from gcc compiler. I have a problem in building xerces in AIX Please reply. Regards, Parthasarathy (1 Reply)
Discussion started by: Parthasarathy
1 Replies

6. Shell Programming and Scripting

Query in linking

Hey guys, i have written the folowing grep command to find an ip address from various files and now i have to find the reverse DNS for it. I wanted to do it via nslookup or host does someone have any clue about how to do it? what i tried was grep -o... (2 Replies)
Discussion started by: snake450
2 Replies

7. Solaris

linking in solaris9

at the end of the compilation in solaris 9. it is showing link error. like..... ld: fatal: library -lgthread-2.0 not found failed to create the binary the library is in /usr/lib and in /usr/local/lib the lib file is present --->libgthread.2.0.so ......etc if i remove... (3 Replies)
Discussion started by: biswajithit
3 Replies

8. AIX

Getting problem in linking using "ldd"

Hi I have one libXYZ.a executable. When i did ldd on that file, it gives me error like "Cannot find /usr/ccs/lib//libpthread.a(shr_xpg5.o)". The same library is loaded by the libABC.a executable. The file location is added to "LIBPATH" variable. And also libpthread.a is present... (4 Replies)
Discussion started by: mail2virag
4 Replies

9. Programming

Linking problem while linking to shared library

Hi I'm getting ld: fatal: option -h and building a dynamic executable are incompatible ld: fatal: Flags processing errors When I run ld -shared -L/usr/dt/lib -lDtSvc -o builtin.so Workspace.o after running gcc -fPIC -I/usr/X11R6/include -I/usr/dt/include -c Workspace.c I'm... (6 Replies)
Discussion started by: laho
6 Replies
Login or Register to Ask a Question