LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-11-2010, 09:15 AM   #1
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
How to use 32 bit C libraries on 64 bit Arch Linux


Just what it says in the title.

I can work in a 32-bit VirtualBox VM, but it's very inconvenient and I would rather work in my 64-bit desktop if that's not too difficult.

These are all the lib32 packages I have installed:

Code:
$ pacman -Qs lib32
local/lib32-gcc-libs 4.4.3-2 (lib32)
    The GNU Compiler Collection
local/lib32-glibc 2.11.1-1.3 (lib32)
    GNU C Library (32 Bit)
 
Old 04-11-2010, 09:24 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
There's no reason your your 32bit code shouldn't run on a 64bit platform, as long as all your library dependencies are present. Also, depending on what you're doing, you may not actually need the std c libs at all ...

cheers
 
Old 04-11-2010, 09:25 AM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
I am using some standard C functions.

Anyway, this is what happens:

Code:
$ nasm -f elf32 main.asm
$ gcc -m32 main.o
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/libgcc.a when searching for -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: ld returned 1 exit status
 
Old 04-11-2010, 09:47 AM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191
Poor choice of thread title. Should have been
How to use 32 bit C libraries on 64 bit Arch Linux

You don't want to attract experts who know about asm. That doesn't matter. You want experts who know about multi lib in Arch. I know about multi lib in Mepis, Ubuntu and Centos.

So far you have determined that gcc can't find the right copy of libgcc.a

The obvious next question is whether the right copy of libgcc.a is installed on your computer.

If it is, you move on to the question of why gcc can't find it. If it isn't, you move on to the question of what package includes it.

For whether it is installed at all, you might try a find command to see all copies of libgcc.a on your hard drive.

If you knew the multi lib rules of Arch better, you could look for it exactly where it is supposed to be. In the gcc multi lib rules of Centos, once we know that the 64 bit version is
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/libgcc.a
that tells us the 32 bit version would be
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/32/libgcc.a

Does that file happen to exist?

Last edited by johnsfine; 04-11-2010 at 09:48 AM.
 
Old 04-11-2010, 09:53 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Looks like I don't have the file.

Code:
$ sudo find / -name 'libgcc.a'
Password: 
/usr/lib/gcc/avr/4.4.3/avr25/libgcc.a
/usr/lib/gcc/avr/4.4.3/avr51/libgcc.a
/usr/lib/gcc/avr/4.4.3/avr5/libgcc.a
/usr/lib/gcc/avr/4.4.3/avr31/libgcc.a
/usr/lib/gcc/avr/4.4.3/avr4/libgcc.a
/usr/lib/gcc/avr/4.4.3/avr6/libgcc.a
/usr/lib/gcc/avr/4.4.3/libgcc.a
/usr/lib/gcc/avr/4.4.3/avr35/libgcc.a
/usr/lib/gcc/avr/4.4.3/avr3/libgcc.a
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/libgcc.a
And should I really just rename this thread (I just really don't understand this 32/64-bit stuff and don't even know where to start)?
 
Old 04-11-2010, 10:05 AM   #6
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191
Quote:
Originally Posted by MTK358 View Post
Looks like I don't have the file.

And should I really just rename this thread
I think so. Do you know how to? (Advanced button while in Edit on your first post of the thread).

Quote:
(I just really don't understand this 32/64-bit stuff and don't even know where to start)?
I don't know Arch and I don't know pacman.

For similar problems in Centos, I would use the command
yum provides "*gcclib.a*"
That lists every available package that contains any file with gcclib.a as part of its name as well as listing the full path and name of the file.

Then I would look through those many choices and apply some common sense to figure out which was right.

But this time in Centos it was too easy, because in each case the 32 bit libgcc.a is included in the same package with the 64 bit one. So I couldn't have gotten into this problem with libgcc.a in Centos.

Apparently Arch packages or installs gcc differently, or did you build your own gcc4.4.3 from source and make a decision during config to leave out the 32 libraries?
 
Old 04-11-2010, 10:18 AM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Code:
$ pacman -hS
usage:  pacman {-S --sync} [options] [package(s)]
options:
      --asdeps         install packages as non-explicitly installed
      --asexplicit     install packages as explicitly installed
  -c, --clean          remove old packages from cache directory (-cc for all)
  -d, --nodeps         skip dependency checks
  -f, --force          force install, overwrite conflicting files
  -g, --groups         view all members of a package group
  -i, --info           view package information
  -l, --list <repo>    view a list of packages in a repo
  -p, --print-uris     print out URIs for given packages and their dependencies
  -s, --search <regex> search remote repositories for matching strings
  -u, --sysupgrade     upgrade installed packages (-uu allows downgrade)
  -w, --downloadonly   download packages but do not install/upgrade anything
  -y, --refresh        download fresh package databases from the server
      --needed         don't reinstall up to date packages
      --ignore <pkg>   ignore a package upgrade (can be used more than once)
      --ignoregroup <grp>
                       ignore a group upgrade (can be used more than once)
  -q, --quiet          show less information for query and search
      --config <path>  set an alternate configuration file
      --logfile <path> set an alternate log file
      --noconfirm      do not ask for any confirmation
      --noprogressbar  do not show a progress bar when downloading files
      --noscriptlet    do not execute the install scriptlet if one exists
  -v, --verbose        be verbose
      --debug          display debug messages
  -r, --root <path>    set an alternate installation root
  -b, --dbpath <path>  set an alternate database location
      --cachedir <dir> set an alternate package cache location
Doesn't look like it lets me find a package containing a certain file, but maybe it's possible.
 
Old 04-11-2010, 11:00 AM   #8
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191
I did a quick google of Arch Linux gcc multilib and found this thread:
http://aur.archlinux.org/packages.php?ID=28545

But I don't know enough about Arch to know if your answer is there.
 
Old 04-11-2010, 11:03 AM   #9
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
I really don't understand that.
 
Old 04-11-2010, 11:33 AM   #10
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191
I poked around a bit more online info on Arch and I realize that while you don't have a 32 bit libgcc.a installed, you do have a 32 bit libgcc_s.so installed.

Instead of
gcc -m32 main.o
try
gcc -m32 -shared-libgcc main.o

I think that tells gcc to use libgcc_s.so instead of libgcc.a

(I'm starting to hate Arch without ever having used it. But that isn't enough to prevent solving the problem.)

Edit: alternately a whole different approach leaps to mind: You already have this stuff working in a VM right? That's just inconvenient to continue using. What version of what OS and what version of gcc did you install in your 32 bit VM? If you happened to choose a similar version of Arch and same version of gcc (but 32 bit builds of each). I think you can copy files such as the 32 bit libgcc.a out of the VM and into appropriate '32' or 'lib32' subdirectories in the main system.

Last edited by johnsfine; 04-11-2010 at 11:43 AM.
 
Old 04-11-2010, 11:50 AM   #11
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949
Blog Entries: 8

Rep: Reputation: 201Reputation: 201Reputation: 201
Adjusting the flags got me past a very similar issue in multilib slackware yesterday.

http://www.linuxquestions.org/questi...ltilib-801222/
 
Old 04-11-2010, 01:11 PM   #12
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
The VM runs 32-bit Arch Linux.

Code:
$ gcc -m32 -shared-libgcc main.o 
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/../../../libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
 
Old 04-11-2010, 01:40 PM   #13
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MTK358 View Post
The VM runs 32-bit Arch Linux.

Code:
$ gcc -m32 -shared-libgcc main.o 
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.3/../../../libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status

Possibly not - "x86_64" might well indicate 64 bits OS.

Try something like this:

Code:
file install/gtk+-2.16.6/lib/libgailutil.so.18.0.1
install/gtk+-2.16.6/lib/libgailutil.so.18.0.1: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped
.


I.e. make explicitly sure you are not running 64 bits stuff.
 
Old 04-11-2010, 01:51 PM   #14
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191
Quote:
Originally Posted by Sergei Steshenko View Post
Possibly not - "x86_64" might well indicate 64 bits OS.
Yes, MTK358 knows the main system he is asking about is X86_64. What he said about the VM was in response to a side suggestion I made for a weird work around for the problem that I don't know the normal solution for in Arch (this stuff is so easy in Centos, Mepis and Ubuntu).

Quote:
Originally Posted by MTK358 View Post
Code:
$ gcc -m32 -shared-libgcc main.o
... 
/usr/bin/ld: cannot find -lgcc_s
My not knowing my way around Arch is continuing to get in the way.

Pursuing that path a little, first make sure I'm right that you really have a 32 bit libgcc_s.so somewhere. You know how to find all the libgcc_s.so files on your system. If unsure about one, you can use the file command to see if it is elf32.

On my Mepis system I just did this (note the backtick character is different from a single quote character)
Code:
 file `find / -name "libgcc_s.so*"`
/emul/ia32-linux/usr/lib/libgcc_s.so.1:           ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, stripped
/usr/lib/gcc/x86_64-linux-gnu/4.3/32/libgcc_s.so: symbolic link to `/emul/ia32-linux/usr/lib/libgcc_s.so.1'
/usr/lib/gcc/x86_64-linux-gnu/4.3/libgcc_s.so:    symbolic link to `/lib/libgcc_s.so.1'
/usr/lib/gcc/x86_64-linux-gnu/4.1/libgcc_s.so:    symbolic link to `/lib/libgcc_s.so.1'
/lib/libgcc_s.so.1:                               ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, stripped
From the output, I can see that the libgcc_s.so in
/usr/lib/gcc/x86_64-linux-gnu/4.3/32/
is a symbolic link to a libgcc_s.so.1 which is elf32. So the directory I want gcc to look in is
/usr/lib/gcc/x86_64-linux-gnu/4.3/32

GCC knows to look there on its own when I do gcc -m32 on this system. But if gcc didn't know that I could force it
Code:
gcc -m32 -L/usr/lib/gcc/x86_64-linux-gnu/4.3/32/ -shared-libgcc main.o

Last edited by johnsfine; 04-11-2010 at 02:09 PM.
 
Old 04-11-2010, 01:59 PM   #15
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949
Blog Entries: 8

Rep: Reputation: 201Reputation: 201Reputation: 201
While this is not specific to your problem or Arch for that matter, it might be a good read. It has some scripts for changing your shell environment to prefer 32 compilers over 64 bit compilers in a multilib system that might be helpful. There are also some links to further reading that might be helpful.

http://alien.slackbook.org/dokuwiki/...kware:multilib
 
  


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
Howto install 32-bit libraries on 64-bit Linux using yum shawn_t Linux - Server 16 07-13-2012 03:46 AM
Wine 32 bit on Slackware 13 64 bit problems: configure can't find some libraries ozanbaba Slackware 28 11-26-2010 03:42 PM
how do I install 32-bit compiler libraries onto a 64-bit machine? charleycat Linux - Software 1 08-16-2007 02:45 PM
Need Linux 64-Bit Distribution CD's for Intel EM64T Arch. amolk Mandriva 1 09-21-2005 05:32 AM
Need Linux 64-Bit Distribution CD's for Intel EM64T Arch. amolk Fedora 1 09-21-2005 05:32 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:33 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration