1

I was googling but I don't find a solution, I want to compile a C program with gcc in 32 bits on a x64 bits Debian system. I use the following command to compile:

gcc -m32 -o programExecutable -L/usr/lib/i386-linux-gnu/ -I/home/secnok/polarssl-  
1.3.5/include/ -I/usr/local/include/libusb-1.0  main.c /home/secnok/polarssl-
1.3.5/library/libpolarssl.a /usr/local/lib/libusb-1.0.a -lpthread -ludev

and I obtain this output:

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux gnu/4.7     
/../../../libudev.so when searching for -ludev /usr/bin/ld: skipping incompatible  
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../libudev.a when searching for -ludev
/usr/bin/ld: skipping incompatible /usr/lib/libudev.so when searching for -ludev
/usr/bin/ld: skipping incompatible /usr/lib/libudev.a when searching for -ludev
/usr/bin/ld: cannot find -ludev

I have installed the libraries gcc++cmultilib and ia32-libs. In the same way, I have exported the path:

export LD_LIBRARY_PATH="/lib32:/usr/lib32:$LD_LIBRARY_PATH"

and it still doesn't compile. This code compiles in x64 without errors, I just want to compile the same code for 32 bits.

KiaMorot
  • 1,668
  • 11
  • 22
AlbertSec
  • 91
  • 1
  • 8
  • http://stackoverflow.com/questions/4250624/ld-library-path-vs-library-path – Lorenzo Boccaccia Sep 12 '14 at 12:43
  • 1
    Probably because `libudev` isn't available for 32bit. – ckruse Sep 12 '14 at 13:01
  • Note that x32 is a mode enabled by `-mx32` compiler switch (32-bit long and pointers in 64-bit mode). The mode enabled by `-m32` is i686. The title is confusing. – Maxim Egorushkin Sep 12 '14 at 15:14
  • ckruse gave the reason. Note that ia32-libs is the "old way". On recent debian (yours is old), you enable multiarch and install libudev-dev:i386. – Marc Glisse Sep 12 '14 at 16:12
  • I have enabled multiarch with `sudo dpkg --add-architecture` and then `sudo apt-get update` and I have installed libudev-dev:i386 wit `sudo apt-get install libudev-dev:i386`, now it shows me `/usr/bin/ld: i386:x86-64 architecture of input file the_paths is incompatible with i386 output`, what it means? – AlbertSec Sep 15 '14 at 08:26

1 Answers1

0

Finally, I found the solution to compile it directly on 32bits statically and now it works. I think in this way, I don't need to worry about libraries compatibility between x64 and x86

AlbertSec
  • 91
  • 1
  • 8