LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-17-2010, 06:21 PM   #1
sysbox
Member
 
Registered: Jul 2005
Posts: 117

Rep: Reputation: 15
32-bit libg2c


I'm trying to compile and link a third-part C/Fortran program in 32-bit mode on a 64-bit machine. I get the following error from the linker:

Code:
/usr/bin/ld: cannot find -lg2c
collect2: ld returned 1 exit status
So, I tried to find libg2c:
Code:
> locate libg2c
/usr/lib64/libg2c.so.0
/usr/lib64/libg2c.so.0.0.0
I think the problem is that's a 64-bit version of libg2c, but I need a 32-bit version. Is that right?

If so, then I need to install a 32-bit version of libg2c, but I don't know how. I did a "yum list | grep g2c" but that didn't find anything. How can I install a 32-bit version of libg2c?
 
Old 02-17-2010, 07:13 PM   #2
marinocuervo
LQ Newbie
 
Registered: Oct 2009
Location: Olympia, Wa
Distribution: Arch Linux
Posts: 3

Rep: Reputation: 0
You are right in assuming that you need the 32 bit version of lib32g2c. I do not have an rpm based system, but I can tell you that libg2c is part of gcc's fortran (gcc-g77) package, so you would have to install the 32 bit version of that package.

--Brennan
 
Old 02-18-2010, 02:15 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
"yum list | grep g2c" → → A precise command is :
# yum provides */libg2c*

compat-libf2c-34-3.4.6-4.i386
/usr/lib/libg2c.so.0 (=>libg2c.so.0.0.0)

compat-gcc-34-g77-3.4.6-4.i386
/usr/lib/gcc/i386-redhat-linux/3.4.6/libg2c.so
/usr/lib/gcc/i386-redhat-linux/3.4.6/libg2c.a

Either can be used ( or both ).
The 32-bit g77 will know, how to find its own libg2c.so ,
but for other applications a link in /usr/lib/ is required.
Like this : cd /usr/lib/
# ln -s libg2c.so.0.0.0 libg2c.so
Or # ln -s gcc/i386-redhat-linux/3.4.6/libg2c.so
.....
The above examples are from a 32-bit OS. EL5.
.....

Last edited by knudfl; 02-18-2010 at 04:49 AM.
 
Old 02-18-2010, 12:40 PM   #4
sysbox
Member
 
Registered: Jul 2005
Posts: 117

Original Poster
Rep: Reputation: 15
Quote:
"yum list | grep g2c" → → A precise command is :
# yum provides */libg2c*
Thanks! I always thought I was doing things wrong with yum, but didn't know.

Anyway, I installed compat-libf2c-34-3.4.6-4.i386, then did an "updatedb", made sure it's location is in my LD_LIBRARY_PATHm, and "locate libg2c" does find several libg2c files:
Code:
> locate libg2c
/usr/lib/libg2c.so
/usr/lib/libg2c.so.0
/usr/lib/libg2c.so.0.0.0
/usr/lib/gcc/x86_64-redhat-linux/3.4.6/libg2c.a
/usr/lib/gcc/x86_64-redhat-linux/3.4.6/libg2c.so
/usr/lib/gcc/x86_64-redhat-linux/3.4.6/32/libg2c.a
/usr/lib/gcc/x86_64-redhat-linux/3.4.6/32/libg2c.so
/usr/lib64/libg2c.so.0
/usr/lib64/libg2c.so.0.0.0
However, when I link my program, the linker still complains
Code:
/usr/bin/ld: cannot find -lg2c
collect2: ld returned 1 exit status
How can that be? What could be wrong?
 
Old 02-18-2010, 12:47 PM   #5
sysbox
Member
 
Registered: Jul 2005
Posts: 117

Original Poster
Rep: Reputation: 15
One more note, I didn't mention that the linker also complains
Code:
/usr/bin/ld: skipping incompatible /usr/lib/libg2c.so when searching for -lg2c
/usr/bin/ld: cannot find -lg2c
collect2: ld returned 1 exit status
Why is that file incompatible? I did
Code:
> file /usr/lib/libg2c.so
/usr/lib/libg2c.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), stripped
while all the other files I'm linking with are
Code:
ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
Could that be it? The "shared object" vs "relocatable" or the stripped vs non-stripped?
 
Old 02-18-2010, 03:04 PM   #6
sysbox
Member
 
Registered: Jul 2005
Posts: 117

Original Poster
Rep: Reputation: 15
I think I figured out the problem. Although each object file was compiled in 32-bit mode, the Makefiles did not specify an -m32 flag for the linker, so the linker was linking in 64-mode and that's why the 32-bit /usr/lib/libg2c.so was incompatible. At least that's the best explanation I can think of.
 
Old 02-18-2010, 07:12 PM   #7
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Yes, to link 32 bit programs, you will also need
a 32 bit linker ( ld ).

And I don't know, how to do that on RHEL / CentOS.
Probably binutils-devel-2.17.50.0.6-12.el5.i386
> binutils-devel.i386, which is available in the x86_64 repo.
.....
P.S. : "Not stripped" is just a standard information.
Shared libraries are not stripped. Binaries are.
http://www.ncsa.illinois.edu/UserInf...mds5/strip.htm
.....

Last edited by knudfl; 02-18-2010 at 07:23 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
libg2c.so.0 in Slackware Alexvader Slackware 16 12-07-2009 01:49 PM
libg2c.so.0 dungminh Linux - Software 1 08-31-2009 01:19 AM
libg2c.so.0 problem uv2005 Linux - Software 1 01-26-2006 08:10 AM
libg2c.so.0 problem uv2005 Programming 2 01-26-2006 07:43 AM
libg2c.so.0 for suse 9.1 petrin SUSE / openSUSE 2 01-28-2005 03:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration