Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
32 bit executables - static linking
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on AMD64
View previous topic :: View next topic  
Author Message
paolog
n00b
n00b


Joined: 10 Nov 2004
Posts: 2
Location: Crema, Italy

PostPosted: Sat Nov 13, 2004 2:04 pm    Post subject: 32 bit executables - static linking Reply with quote

I need to compile on my new AMD64 workstation a program that mixes C with x86 assembly, and link it statically with several libraries (for example libpcre). Compiling the sources with the -m32 flag works flawlessly, but linking fails.

I reduced the problem to this minimalistic example:
Code:
#include <stdio.h>

int main(int argc, char **argv)
{
  printf("Sizeof long: %d\n", sizeof(long));
}


When linking, I get the following error:
Code:
$ gcc --static example.c -m32 -lpcre
/usr/lib/gcc-lib/x86_64-pc-linux-gnu/3.3.4/../../../../x86_64-pc-linux-gnu/bin/ld:
skipping incompatible /usr/lib/gcc-lib/x86_64-pc-linux-gnu/3.3.4/../../../libpcre.a when searching for -lpcre
/usr/lib/gcc-lib/x86_64-pc-linux-gnu/3.3.4/../../../../x86_64-pc-linux-gnu/bin/ld:
skipping incompatible /usr/lib/libpcre.a when searching for -lpcre
/usr/lib/gcc-lib/x86_64-pc-linux-gnu/3.3.4/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lpcre
collect2: ld returned 1 exit status


How can I build a 32 bit version of libpcre (and the other libraries I need) under /usr/lib32?

Some background information on my system:
Code:
$ gcc -v
Reading specs from /usr/lib/gcc-lib/x86_64-pc-linux-gnu/3.3.4/specs
Configured with: /var/tmp/portage/gcc-3.3.4-r1/work/gcc-3.3.4/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/3.3 --includedir=/usr/lib/gcc-lib/x86_64-pc-linux-gnu/3.3.4/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/3.3 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/3.3/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/3.3/info --enable-shared --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --with-system-zlib --enable-languages=c,c++,f77 --enable-threads=posix --enable-long-long --disable-checking --disable-libunwind-exceptions --enable-cstdio=stdio --enable-version-specific-runtime-libs --with-gxx-include-dir=/usr/lib/gcc-lib/x86_64-pc-linux-gnu/3.3.4/include/g++-v3--with-local-prefix=/usr/local --enable-shared --enable-nls --without-included-gettext --enable-multilib --enable-__cxa_atexit --enable-clocale=generic
Thread model: posix
gcc version 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)

$ cat /ect/make.conf
# These settings were set by the catalyst build script that automatically builtthis stage
# Please consult /etc/make.conf.example for a more detailed example
CFLAGS="-O2"
CHOST="x86_64-pc-linux-gnu"
CXXFLAGS="${CFLAGS}"
MAKEOPTS="-j2"
GENTOO_MIRRORS="http://mirror.switch.ch/mirror/gentoo/ http://gentoo.inode.at/ http://trumpetti.atm.tut.fi/gentoo/"
USE="alsa doc dvd cdr sockets crypt cups dbm dvdr dbx emacs gd gnome gphoto2 imagemagick java kde mbox mime mozilla multilib mysql opengl oss pam pcre pdflib perl png qt quicktime readline spell tcpd tetex theora tiff truetype unicode usb xmms zlib"
ALSA_CARDS="emu10k1"


Thanks in advance for your help.
Back to top
View user's profile Send private message
paolog
n00b
n00b


Joined: 10 Nov 2004
Posts: 2
Location: Crema, Italy

PostPosted: Sun Nov 14, 2004 8:11 am    Post subject: Clarification Reply with quote

I managed to compile 32 bit versions of the libraries I needed, as follows:

Code:
$ tar xjf /usr/portage/distfiles/foo-1.2.3.tar.bz2
$ cd foo-1.2.3
$ CFLAGS="-m32 (other_flags)" LDFLAGS=-m32 ./configure
$ make

and then I installed the contents of .libs into /usr/lib32/ by hand.

What I'd like to know is, is there a standard way to automate the process and integrate it into emerge?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on AMD64 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum