[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 582
  • Last Modified:

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

0
Cyber-EE
Asked:
Cyber-EE
  • 12
  • 12
  • 5
2 Solutions
 
ahoffmannCommented:
errno 12 is "out of memory"
so most likely your system is low in memory while running ld
0
 
gheistCommented:
This means that you use ld and collect from different worlds - one from xLc other from GNU binutils
0
 
Cyber-EEAuthor Commented:
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?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
gheistCommented:
gcc expects GNU ld to be first in the path. You have IBM's one that will not work with GCC
0
 
Cyber-EEAuthor Commented:
ok - how do I change that (if this is the case)?
how do I check if this is the wrong ld?
0
 
Cyber-EEAuthor Commented:
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
0
 
Cyber-EEAuthor Commented:
and:
ls -l `which gcc`
returns:
/usr/bin/gcc -> /export/inst/gcc-3.4.6-sources/gcc-3.4.6/gcc/xgcc
0
 
gheistCommented:
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
0
 
Cyber-EEAuthor Commented:
rpm -q gcc =>
gcc-4.0.0-1

rpm -q binutils=>
binutils-2.14-3
0
 
gheistCommented:
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.
0
 
ahoffmannCommented:
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.
0
 
Cyber-EEAuthor Commented:
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?
0
 
gheistCommented:
This error comes from AIX ld.
0
 
Cyber-EEAuthor Commented:
/usr/bin/ld -> /opt/freeware/bin/gld

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


0
 
Cyber-EEAuthor Commented:
so - how can I solve this?
0
 
Cyber-EEAuthor Commented:
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
0
 
ahoffmannCommented:
use gcc's  -Bprefix  option where prefix is the path where to find the used executables
0
 
gheistCommented:
Do you have GNU ld in your $PATH first?
check using: ld --version
0
 
ahoffmannCommented:
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
0
 
gheistCommented:
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.
0
 
ahoffmannCommented:
fine, as we clarified the PATH issue, the -B option comes into the game again ..
0
 
Cyber-EEAuthor Commented:
Just to clarify gheist,
The linking is failed only when not striping!
When I use the -s option, link goes fine.
0
 
gheistCommented:
Then it is some kind of symbols version issue - have you updated only one - binutils or gcc alone?
0
 
Cyber-EEAuthor Commented:
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
0
 
gheistCommented:
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.
0
 
Cyber-EEAuthor Commented:
solved.tx
0
 
gheistCommented:
Thanks how?
0
 
gheistCommented:
Those comments basically evolved towards possible solutions later:
http:#21763825
http:#21777637
Nobody can tell which of the later posts did the trick.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 12
  • 12
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now