LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   32-bit libg2c (https://www.linuxquestions.org/questions/linux-software-2/32-bit-libg2c-789819/)

sysbox 02-17-2010 06:21 PM

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?

marinocuervo 02-17-2010 07:13 PM

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

knudfl 02-18-2010 02:15 AM

"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.
.....

sysbox 02-18-2010 12:40 PM

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?

sysbox 02-18-2010 12:47 PM

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?

sysbox 02-18-2010 03:04 PM

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.

knudfl 02-18-2010 07:12 PM

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
.....


All times are GMT -5. The time now is 12:47 PM.