Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Both 32 and 64 bit compiles worked and then I upgraded from 11.10 to 12.04. Now -m64 works but -m32 can't find libraries.

I've tried reinstalling libraries, and gcc-multilib but no joy. Anyone spot something I've missed?

David

gcc -m32 -Wall -W -L/usr/lib/x86_64-linux-gnu/libusb-1.0.so.0 -lusb-1.0
-lX11 LMSS.c -o LMSS32
/usr/bin/ld: skipping incompatible /usr/local/lib/libusb-1.0.so when searching for -lusb-1.0
/usr/bin/ld: skipping incompatible /usr/local/lib/libusb-1.0.a when searching for -lusb-1.0
/usr/bin/ld: cannot find -lusb-1.0
/usr/bin/ld: cannot find -lX11
collect2: ld returned 1 exit status

locate libusb-1.0
/home/david/Downloads/libusb-1.0.8
/home/david/Downloads/libusb-1.0.8.tar.bz2
/home/david/Downloads/libusb-1.0.8/AUTHORS
/home/david/Downloads/libusb-1.0.8/COPYING
/home/david/Downloads/libusb-1.0.8/ChangeLog
/home/david/Downloads/libusb-1.0.8/INSTALL
/home/david/Downloads/libusb-1.0.8/Makefile
/home/david/Downloads/libusb-1.0.8/Makefile.am
/home/david/Downloads/libusb-1.0.8/Makefile.in
/home/david/Downloads/libusb-1.0.8/NEWS
/home/david/Downloads/libusb-1.0.8/PORTING
/home/david/Downloads/libusb-1.0.8/README
/home/david/Downloads/libusb-1.0.8/THANKS
/home/david/Downloads/libusb-1.0.8/TODO
/home/david/Downloads/libusb-1.0.8/aclocal.m4
/home/david/Downloads/libusb-1.0.8/compile
/home/david/Downloads/libusb-1.0.8/config.guess
/home/david/Downloads/libusb-1.0.8/config.h
/home/david/Downloads/libusb-1.0.8/config.h.in
/home/david/Downloads/libusb-1.0.8/config.log
/home/david/Downloads/libusb-1.0.8/config.status
/home/david/Downloads/libusb-1.0.8/config.sub
/home/david/Downloads/libusb-1.0.8/configure
/home/david/Downloads/libusb-1.0.8/configure.ac
/home/david/Downloads/libusb-1.0.8/depcomp
/home/david/Downloads/libusb-1.0.8/doc
/home/david/Downloads/libusb-1.0.8/examples
/home/david/Downloads/libusb-1.0.8/install-sh
/home/david/Downloads/libusb-1.0.8/libtool
/home/david/Downloads/libusb-1.0.8/libusb
/home/david/Downloads/libusb-1.0.8/libusb-1.0.pc
/home/david/Downloads/libusb-1.0.8/libusb-1.0.pc.in
/home/david/Downloads/libusb-1.0.8/ltmain.sh
/home/david/Downloads/libusb-1.0.8/missing
/home/david/Downloads/libusb-1.0.8/stamp-h1
/home/david/Downloads/libusb-1.0.8/doc/Makefile
/home/david/Downloads/libusb-1.0.8/doc/Makefile.am
/home/david/Downloads/libusb-1.0.8/doc/Makefile.in
/home/david/Downloads/libusb-1.0.8/doc/doxygen.cfg
/home/david/Downloads/libusb-1.0.8/doc/doxygen.cfg.in
/home/david/Downloads/libusb-1.0.8/examples/.deps
/home/david/Downloads/libusb-1.0.8/examples/Makefile
/home/david/Downloads/libusb-1.0.8/examples/Makefile.am
/home/david/Downloads/libusb-1.0.8/examples/Makefile.in
/home/david/Downloads/libusb-1.0.8/examples/dpfp.c
/home/david/Downloads/libusb-1.0.8/examples/dpfp_threaded.c
/home/david/Downloads/libusb-1.0.8/examples/lsusb.c
/home/david/Downloads/libusb-1.0.8/examples/.deps/dpfp.Po
/home/david/Downloads/libusb-1.0.8/examples/.deps/dpfp_threaded-dpfp_threaded.Po
/home/david/Downloads/libusb-1.0.8/examples/.deps/lsusb.Po
/home/david/Downloads/libusb-1.0.8/libusb/.deps
/home/david/Downloads/libusb-1.0.8/libusb/.libs
/home/david/Downloads/libusb-1.0.8/libusb/Makefile
/home/david/Downloads/libusb-1.0.8/libusb/Makefile.am
/home/david/Downloads/libusb-1.0.8/libusb/Makefile.in
/home/david/Downloads/libusb-1.0.8/libusb/core.c
/home/david/Downloads/libusb-1.0.8/libusb/descriptor.c
/home/david/Downloads/libusb-1.0.8/libusb/io.c
/home/david/Downloads/libusb-1.0.8/libusb/libusb-1.0.la
/home/david/Downloads/libusb-1.0.8/libusb/libusb.h
/home/david/Downloads/libusb-1.0.8/libusb/libusb_1_0_la-core.lo
/home/david/Downloads/libusb-1.0.8/libusb/libusb_1_0_la-core.o
/home/david/Downloads/libusb-1.0.8/libusb/libusb_1_0_la-descriptor.lo
/home/david/Downloads/libusb-1.0.8/libusb/libusb_1_0_la-descriptor.o
/home/david/Downloads/libusb-1.0.8/libusb/libusb_1_0_la-io.lo
/home/david/Downloads/libusb-1.0.8/libusb/libusb_1_0_la-io.o
/home/david/Downloads/libusb-1.0.8/libusb/libusb_1_0_la-linux_usbfs.lo
/home/david/Downloads/libusb-1.0.8/libusb/libusb_1_0_la-linux_usbfs.o
/home/david/Downloads/libusb-1.0.8/libusb/libusb_1_0_la-sync.lo
/home/david/Downloads/libusb-1.0.8/libusb/libusb_1_0_la-sync.o
/home/david/Downloads/libusb-1.0.8/libusb/libusbi.h
/home/david/Downloads/libusb-1.0.8/libusb/os
/home/david/Downloads/libusb-1.0.8/libusb/sync.c
/home/david/Downloads/libusb-1.0.8/libusb/.deps/libusb_1_0_la-core.Plo
/home/david/Downloads/libusb-1.0.8/libusb/.deps/libusb_1_0_la-darwin_usb.Plo
/home/david/Downloads/libusb-1.0.8/libusb/.deps/libusb_1_0_la-descriptor.Plo
/home/david/Downloads/libusb-1.0.8/libusb/.deps/libusb_1_0_la-io.Plo
/home/david/Downloads/libusb-1.0.8/libusb/.deps/libusb_1_0_la-linux_usbfs.Plo
/home/david/Downloads/libusb-1.0.8/libusb/.deps/libusb_1_0_la-sync.Plo
/home/david/Downloads/libusb-1.0.8/libusb/.libs/libusb-1.0.a
/home/david/Downloads/libusb-1.0.8/libusb/.libs/libusb-1.0.la
/home/david/Downloads/libusb-1.0.8/libusb/.libs/libusb-1.0.lai
/home/david/Downloads/libusb-1.0.8/libusb/.libs/libusb-1.0.so
/home/david/Downloads/libusb-1.0.8/libusb/.libs/libusb-1.0.so.0
/home/david/Downloads/libusb-1.0.8/libusb/.libs/libusb-1.0.so.0.0.0
/home/david/Downloads/libusb-1.0.8/libusb/.libs/libusb_1_0_la-core.o
/home/david/Downloads/libusb-1.0.8/libusb/.libs/libusb_1_0_la-descriptor.o
/home/david/Downloads/libusb-1.0.8/libusb/.libs/libusb_1_0_la-io.o
/home/david/Downloads/libusb-1.0.8/libusb/.libs/libusb_1_0_la-linux_usbfs.o
/home/david/Downloads/libusb-1.0.8/libusb/.libs/libusb_1_0_la-sync.o
/home/david/Downloads/libusb-1.0.8/libusb/os/darwin_usb.c
/home/david/Downloads/libusb-1.0.8/libusb/os/darwin_usb.h
/home/david/Downloads/libusb-1.0.8/libusb/os/linux_usbfs.c
/home/david/Downloads/libusb-1.0.8/libusb/os/linux_usbfs.h
/lib/x86_64-linux-gnu/libusb-1.0.so.0
/lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0
/usr/include/libusb-1.0
/usr/include/libusb-1.0/libusb.h
/usr/lib/x86_64-linux-gnu/libusb-1.0.a
/usr/lib/x86_64-linux-gnu/libusb-1.0.so
/usr/lib/x86_64-linux-gnu/libusb-1.0.so.0
/usr/lib/x86_64-linux-gnu/pkgconfig/libusb-1.0.pc
/usr/local/include/libusb-1.0
/usr/local/include/libusb-1.0/libusb.h
/usr/local/lib/libusb-1.0.a
/usr/local/lib/libusb-1.0.la
/usr/local/lib/libusb-1.0.so
/usr/local/lib/libusb-1.0.so.0
/usr/local/lib/libusb-1.0.so.0.0.0
/usr/local/lib/pkgconfig/libusb-1.0.pc
/usr/share/doc/libusb-1.0-0
/usr/share/doc/libusb-1.0-0-dev
/usr/share/doc/libusb-1.0-0/README
/usr/share/doc/libusb-1.0-0/changelog.Debian.gz
/usr/share/doc/libusb-1.0-0/copyright
/usr/share/doc/libusb-1.0-0-dev/PORTING
/usr/share/doc/libusb-1.0-0-dev/README
/usr/share/doc/libusb-1.0-0-dev/changelog.Debian.gz
/usr/share/doc/libusb-1.0-0-dev/copyright
/usr/share/doc/libusb-1.0-0-dev/html
/usr/share/doc/libusb-1.0-0-dev/html/annotated.html
/usr/share/doc/libusb-1.0-0-dev/html/bc_s.png
/usr/share/doc/libusb-1.0-0-dev/html/caveats.html
/usr/share/doc/libusb-1.0-0-dev/html/classes.html
/usr/share/doc/libusb-1.0-0-dev/html/closed.png
/usr/share/doc/libusb-1.0-0-dev/html/contexts.html
/usr/share/doc/libusb-1.0-0-dev/html/doxygen.css
/usr/share/doc/libusb-1.0-0-dev/html/doxygen.png
/usr/share/doc/libusb-1.0-0-dev/html/dynsections.js
/usr/share/doc/libusb-1.0-0-dev/html/files.html
/usr/share/doc/libusb-1.0-0-dev/html/functions.html
/usr/share/doc/libusb-1.0-0-dev/html/functions_vars.html
/usr/share/doc/libusb-1.0-0-dev/html/group__asyncio.html
/usr/share/doc/libusb-1.0-0-dev/html/group__desc.html
/usr/share/doc/libusb-1.0-0-dev/html/group__dev.html
/usr/share/doc/libusb-1.0-0-dev/html/group__lib.html
/usr/share/doc/libusb-1.0-0-dev/html/group__misc.html
/usr/share/doc/libusb-1.0-0-dev/html/group__poll.html
/usr/share/doc/libusb-1.0-0-dev/html/group__syncio.html
/usr/share/doc/libusb-1.0-0-dev/html/index.html
/usr/share/doc/libusb-1.0-0-dev/html/io.html
/usr/share/doc/libusb-1.0-0-dev/html/libusb_8h_source.html
/usr/share/doc/libusb-1.0-0-dev/html/modules.html
/usr/share/doc/libusb-1.0-0-dev/html/mtasync.html
/usr/share/doc/libusb-1.0-0-dev/html/nav_f.png
/usr/share/doc/libusb-1.0-0-dev/html/nav_h.png
/usr/share/doc/libusb-1.0-0-dev/html/open.png
/usr/share/doc/libusb-1.0-0-dev/html/packetoverflow.html
/usr/share/doc/libusb-1.0-0-dev/html/pages.html
/usr/share/doc/libusb-1.0-0-dev/html/structlibusb__config__descriptor.html
/usr/share/doc/libusb-1.0-0-dev/html/structlibusb__control__setup.html
/usr/share/doc/libusb-1.0-0-dev/html/structlibusb__device__descriptor.html
/usr/share/doc/libusb-1.0-0-dev/html/structlibusb__endpoint__descriptor.html
/usr/share/doc/libusb-1.0-0-dev/html/structlibusb__interface.html
/usr/share/doc/libusb-1.0-0-dev/html/structlibusb__interface__descriptor.html
/usr/share/doc/libusb-1.0-0-dev/html/structlibusb__iso__packet__descriptor.html
/usr/share/doc/libusb-1.0-0-dev/html/structlibusb__pollfd.html
/usr/share/doc/libusb-1.0-0-dev/html/structlibusb__transfer.html
/usr/share/doc/libusb-1.0-0-dev/html/tab_a.png
/usr/share/doc/libusb-1.0-0-dev/html/tab_b.png
/usr/share/doc/libusb-1.0-0-dev/html/tab_h.png
/usr/share/doc/libusb-1.0-0-dev/html/tab_s.png
/usr/share/doc/libusb-1.0-0-dev/html/tabs.css
/usr/share/doc/libusb-1.0-0-dev/html/version_8h_source.html
/usr/share/doc-base/libusb-1.0-0-dev
/var/cache/apt/archives/libusb-1.0-0-dev_2%3a1.0.9~rc3-2ubuntu1_amd64.deb
/var/cache/apt/archives/libusb-1.0-0_2%3a1.0.9~rc3-2ubuntu1_amd64.deb
/var/lib/doc-base/documents/libusb-1.0-0-dev
/var/lib/doc-base/omf/libusb-1.0-0-dev
/var/lib/doc-base/omf/libusb-1.0-0-dev/libusb-1.0-0-dev-C.omf
/var/lib/dpkg/info/libusb-1.0-0-dev.list
/var/lib/dpkg/info/libusb-1.0-0-dev.md5sums
/var/lib/dpkg/info/libusb-1.0-0:amd64.list
/var/lib/dpkg/info/libusb-1.0-0:amd64.md5sums
/var/lib/dpkg/info/libusb-1.0-0:amd64.postinst
/var/lib/dpkg/info/libusb-1.0-0:amd64.postrm
/var/lib/dpkg/info/libusb-1.0-0:amd64.shlibs
share|improve this question
    
First, you are listing a file after the the -L flag, instead of a directory. Secondly, /usr/lib/x86_64-linux-gnu constains 64-bit libraries, not 32 bit. Are you trying to cross-compile from 64 bit system to 32 bits? –  Michael Wild Apr 29 '12 at 11:46
    
I corrected the -L flag and then got more incompatible libs so I am obviously missing the 32 bit libs. Any pointers as to where they will be? I'm really annoyed I upgraded as I had everything working before. David –  David Apr 29 '12 at 13:40
    
11.10 gcc LMSS.c -m64 -Wall -W -lusb-1.0 -lx11 -o LMSS64 gcc and LMSS.c -m32 -Wall -W -lusb-1.0 -lx11 -o LMSS32 worked 12.04 gcc LMSS.c -m64 -Wall -W -lusb-1.0 -lx11 -o LMSS64 works and I just need to sort 32bit compile for 32 bit target. David –  David Apr 29 '12 at 13:44

2 Answers 2

You could install the 32-bit packages for these libraries:

$ sudo apt-get install libusb-dev:i386 libX11-dev:i386

Note, however, that this will remove the 64-bit versions. Probably it's better to use a chroot (e.g. with cowbuilder or pbuilder) or Qemu image for this kind of thing. E.g. create the file ~/.pbuilderrc-precise-i386:

# Set this to the distribution you want to build for
DISTRIBUTION=precise
# The architecture you want to build for
ARCHITECTURE=i386
# The directory in which to store the chroot base image
BASEPATH=/var/cache/pbuilder/base-precise-i386.cow
# The repositories to be enabled in the /etc/apt/sources.list
COMPONENTS="main universe"
# If you want to speed things up with ccache, enable these options
export CCACHE_DIR="/var/cache/pbuilder/ccache"
export PATH="/usr/lib/ccache:${PATH}"
# List here all packages you need to build your software
# (e.g. build-essential, libusb-dev, libX11-dev, etc.)
EXTRAPACKAGES=ccache
# List here all directories from you system that should be visible inside the chroot
BINDMOUNTS="${CCACHE_DIR} ${HOME}/projects"

Then install cowbuilder and create the base image as follows:

$ sudo apt-get install cowbuilder
$ sudo cowbuilder --create --configfile ~/.pbuilderrc-precise-i386

Lastly, enter the chroot and finish configuring it (copy over configuration files:

$ sudo cowbuilder --login --save-after-exec --configfile ~/.pbuilderrc-precise-i386

You can exit the chroot using Ctrl+D or using exit. Now you have set up your base-image. In the future, don't use the --save-after-exec flag any more when entering the chroot. This ensures that all the modifications will be discarded after you leave the chroot, ensuring a clean build environment for future builds.

Now you should be able to enter the chroot and build your software:

$ sudo cowbuilder --login --configfile ~/.pbuilderrc-precise-i386
% cd $HOME/projects/foo
% # build project foo

Note, however, that the files created in this way will be owned by root. Hence, out-of-source builds are a very good idea.

share|improve this answer
    
Thanks I'll have a play with that. I think ia32-libs is broken and so I installed 32 bit libs for libusb and x11. I had to reinstall gcc but it is up and running - enough for my current need. I'll look at chroot approach and let you know how I get on. –  David Apr 30 '12 at 8:22

Something is broken with multiarch, I could no longer compile 32-bit apps on 64-bit machine with fresh 12.04.1 and its multiarch (everything installed) using -m32 switch. In my case I needed libQtCore and any attempt to install libqt4-dev:i386 tried to unsinstall libqt4-dev! After fiddling around I figured out some symbolic links were missing in "/usr/lib/i386-linux-gnu" then compile proceeded.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.