Solved

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

Posted on 2008-06-11
32
546 Views
Last Modified: 2013-12-26
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
Comment
Question by:Cyber-EE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 12
  • 5
32 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 250 total points
ID: 21763825
errno 12 is "out of memory"
so most likely your system is low in memory while running ld
0
 
LVL 62

Assisted Solution

by:gheist
gheist earned 250 total points
ID: 21777637
This means that you use ld and collect from different worlds - one from xLc other from GNU binutils
0
 

Author Comment

by:Cyber-EE
ID: 21972859
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 62

Expert Comment

by:gheist
ID: 21973032
gcc expects GNU ld to be first in the path. You have IBM's one that will not work with GCC
0
 

Author Comment

by:Cyber-EE
ID: 21973174
ok - how do I change that (if this is the case)?
how do I check if this is the wrong ld?
0
 

Author Comment

by:Cyber-EE
ID: 21973329
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
 

Author Comment

by:Cyber-EE
ID: 21973424
and:
ls -l `which gcc`
returns:
/usr/bin/gcc -> /export/inst/gcc-3.4.6-sources/gcc-3.4.6/gcc/xgcc
0
 
LVL 62

Expert Comment

by:gheist
ID: 21976220
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
 

Author Comment

by:Cyber-EE
ID: 21991271
rpm -q gcc =>
gcc-4.0.0-1

rpm -q binutils=>
binutils-2.14-3
0
 
LVL 62

Expert Comment

by:gheist
ID: 21991585
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 21991618
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
 

Author Comment

by:Cyber-EE
ID: 21991643
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
 
LVL 62

Expert Comment

by:gheist
ID: 21991651
This error comes from AIX ld.
0
 

Author Comment

by:Cyber-EE
ID: 21991668
/usr/bin/ld -> /opt/freeware/bin/gld

1. so? what can I do about that?
2. do you know what lrgpage is?
0
 
LVL 62

Expert Comment

by:gheist
ID: 21991684
0711-152 error means that AIX LD did not find required library.


0
 

Author Comment

by:Cyber-EE
ID: 21991691
so - how can I solve this?
0
 

Author Comment

by:Cyber-EE
ID: 21992110
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 21994324
use gcc's  -Bprefix  option where prefix is the path where to find the used executables
0
 
LVL 62

Expert Comment

by:gheist
ID: 21996016
Do you have GNU ld in your $PATH first?
check using: ld --version
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 21996182
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
 
LVL 62

Expert Comment

by:gheist
ID: 21996210
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 21996246
fine, as we clarified the PATH issue, the -B option comes into the game again ..
0
 

Author Comment

by:Cyber-EE
ID: 21997153
Just to clarify gheist,
The linking is failed only when not striping!
When I use the -s option, link goes fine.
0
 
LVL 62

Expert Comment

by:gheist
ID: 21997181
Then it is some kind of symbols version issue - have you updated only one - binutils or gcc alone?
0
 

Author Comment

by:Cyber-EE
ID: 21997213
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
 
LVL 62

Expert Comment

by:gheist
ID: 21998636
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
 

Author Comment

by:Cyber-EE
ID: 25468059
solved.tx
0
 
LVL 62

Expert Comment

by:gheist
ID: 25487607
Thanks how?
0
 
LVL 62

Expert Comment

by:gheist
ID: 25503122
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question