Solved

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

Posted on 2008-06-11
32
508 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
  • 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 61

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
 
LVL 61

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 61

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 61

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 61

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 61

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 61

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 61

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 61

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 61

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 61

Expert Comment

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
List out all word 7 259
conditional code and condition difference 9 77
How to convert MFC::CString to UTF8 wchar_t* 10 142
mapAB Challlenge 35 124
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now