Link to home
Start Free TrialLog in
Avatar of Cyber-EE
Cyber-EE

asked on

AIX - link failure when not using strip (collect2: ld returned 12 exit status)

Hi,
I have a new problem that suddenly happened:
My product was compiled with no problem, on both debug - without strip (-s) and on release - with strip.
Suddenly when trying to generate the executable on debug mode (without strip), I got the following link problem: "collect2: ld returned 12 exit status"
As you can see, the problem is in the linking phase, with no more details to help me find its problem.
Notes:
1. The only difference between debug and release in my Makefile, is the fact that for release I added "-Xlinker -s" (strip)
2. I don't have a space or memory problem as far as I know...

Any idea?!

tx,
shlom

ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cyber-EE
Cyber-EE

ASKER

hi again,

I'm back in this problem.
I'm using gcc 3.4.6
I'm not usign ld directly but via the gcc command.
I don't have a memory problem on the machine.
What else can I try?
gcc expects GNU ld to be first in the path. You have IBM's one that will not work with GCC
ok - how do I change that (if this is the case)?
how do I check if this is the wrong ld?
when I run
find / -name ld -print
I get these files - when the first is a link to the second one.

/usr/bin/ld
/usr/ccs/bin/ld


tx
and:
ls -l `which gcc`
returns:
/usr/bin/gcc -> /export/inst/gcc-3.4.6-sources/gcc-3.4.6/gcc/xgcc
ld --version
AIX version does not display version, GNU version displays one.
if your gcc is installed from rpm collection then binutils has to be installed from same
check with rpm -q gcc ; rpm -q binutils
rpm -q gcc =>
gcc-4.0.0-1

rpm -q binutils=>
binutils-2.14-3
Run "which ld" and ld --version

You are invoking different ld, not GNU one. Adjust path so `which ld` and 'ld --version' clearly display GNU version. Only after that gcc will start to link binaries.
keep in mind that "which" is unreliable, in particular for ld when used from within gcc it may give you a complete false information (as the linker path may be hardcoded or based on the gcc's path).
Better try to start your compiler with the -v option which should report which linker and how it is called.
great.
I used gld instead and got more info:

ld: 0711-152 SEVERE ERROR: Invalid binder command: lrgpage
collect2: ld returned 12 exit status

any idea now?
This error comes from AIX ld.
/usr/bin/ld -> /opt/freeware/bin/gld

1. so? what can I do about that?
2. do you know what lrgpage is?
0711-152 error means that AIX LD did not find required library.


so - how can I solve this?
b.t.w
The msg 0711-152 is not relevant since I got it for all of my executable linking => I moved back to the original ld.
=>
I came back to the orig problem, which is "collect2: ld returned 12 exit status"....


tx
use gcc's  -Bprefix  option where prefix is the path where to find the used executables
Do you have GNU ld in your $PATH first?
check using: ld --version
gheist, my gcc (internal) knowlege is a bit rusty, but AFAIK gcc checks for compiled in PATHs first before using environment variable $PATH, unless told otherwise by options
simply using
  gcc -v .....
tells you the truth
AIX gcc has compiled-in default 'ld' , so $PATH comes in play.

Another linker error might be cross referencing symbols.

AIX linker does not read GNU export tables, so it fails like strip was used.
fine, as we clarified the PATH issue, the -B option comes into the game again ..
Just to clarify gheist,
The linking is failed only when not striping!
When I use the -s option, link goes fine.
Then it is some kind of symbols version issue - have you updated only one - binutils or gcc alone?
This might br the situation.
(Keep in mind that it work for the release version)
How can I confirm it and make sure I have *all* the correct files?!

tx
http://gcc.gnu.org release notes do list compatible binutils packages for each gcc.
It is hell lot of work - updating both to current releases form IBM would be much easier.
solved.tx
Thanks how?
Those comments basically evolved towards possible solutions later:
http:#21763825
http:#21777637
Nobody can tell which of the later posts did the trick.