OpenWrt Forum Archive

Topic: Cross compiling code missing libltdl

The content of this topic has been archived on 14 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Trying to cross compile gphoto2 and hit this error during configure:
checking ltdl.h usability... no
checking ltdl.h presence... no
checking for ltdl.h... no
checking that we can compile and link with libltdl... no
configure: error: cannot compile and link against libltdl
libgphoto2 requires libltdl (the libtool dl* library),
but cannot compile and link against it.
Aborting.

Get the same error with both
./configure --build=x86_64-unknown-linux-gnu -host=mips-openwrt-linux-uclibc
and
./configure --build=x86_64-unknown-linux-gnu -host=mips-openwrt-linux-uclibc -libdir=/home/wire/openwrt/staging_dir/host/lib/ -includedir=/home/wire/openwrt/staging_dir/host/include/

Not a code guy so not quite sure where to go from here.

basically the compiler its telling you that you need to install libltdl in order to link against it...


depending on what Linux you are running, try

 sudo yum install libtool-ltdl-devel 

or ubuntu

 sudo apt-get install libtool-ltdl-devel 

Ok did a:
sudo apt-get install libtool
sudo apt-get install libltdl-dev
which updated the version on my local Ubuntu machine. But the cross compile configure still fails with the same message. Do I need to make a copy of those lib somewhere special for the cross compile to use?

well it seems the libgphoto2 src page is down so i can not download the src and recreate the error you are getting. That makes it tuff to say for certain what the problem may be. I recommend you get it compiling natively, that way you know that you have all the dependencies required to compile it successfully. Once you can compile it for ubuntu, then you can start the cross compiling adventure

Took your advice and got it to compile and run on my machine. Blow by blow below...

First verified it was not already installed and my vanilla ubuntu install did not have it by default.


sudo apt-get update
sudo apt-get install libudev-dev 
(yep was lazy and did not want to find the source. But if needed will go get it)

Downloaded "libusb-1.0.19.tar.bz2" unpacked it
./configure
make
sudo make install

Downloaded "libgphoto2-2.5.7.tar.bz2" unpacked it
./configure --prefix=/usr/local
(per the INSTALL readme)
make
sudo make install

sudo apt-get install libpopt-dev 
(yep was lazy again)

Downloaded "gphoto2-2.5.6.tar.bz2" and unpacked it
./configure
make
sudo make install

tried running "gphoto2 --list-ports" and got a "gphoto2: error while loading shared libraries: libgphoto2_port.so.12: cannot open shared object file: No such file or directory "

Some reading later and a "sudo ldconfig" and now not only does --list-ports work but also --auto-detect finds my camera:

wire@wire-thinkpad:~/Downloads/libgphoto2-2.5.7$ gphoto2 --auto-detect
Model                          Port
----------------------------------------------------------
Canon PowerShot A3100 IS       usb:001,004


So now have a working native build.



Went back to my cross compile setup and got the same libltdl error. Maybe I need to build that first in the cross compile environment?

wire wrote:

Ok did a:
sudo apt-get install libtool
sudo apt-get install libltdl-dev
which updated the version on my local Ubuntu machine. But the cross compile configure still fails with the same message. Do I need to make a copy of those lib somewhere special for the cross compile to use?

Unless you are trying to compile the package for the host platform, why would you bother to install the above host packages? What you need is to compile/install libtool package from tools, i.e. make tools/libtool/{compile,install}, needed by the cross compiler/linker.

Just was following the directions given above first time trying to cross compile anything.

went and grabbed "libtool-2.4.6.tar.gz" and unpacked it.
Ran the following:
PATH=$PATH:/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/
export PATH
STAGING_DIR=/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/
export STAGING_DIR
./configure --build=x86_64-unknown-linux-gnu -host=mips-openwrt-linux-uclibc --prefix=/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr
make
make install

That completed with no errors.

Then went back to libgphoto2 and did the same up to configure. Good news is it got past the errors and completed. Bad new is usb support was missing (sort of need that for my camera).

So went and tried to compile libusb-1.0.19 using the same methods and fail during configure for:
configure: error: "udev support requested but libudev not installed"

Any ideas where I can find the source for libudev or better yet is there a way to copy the libusb-1.0 library off my router? (checked and it is installed) Would it be as easy as copying the files from /usr/lib/ on the router to /usr/lib in the toolchain directory above?

Thanks again,

Ok used the following to build the libusb-1.0 files:

PATH=$PATH:/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/
export PATH
STAGING_DIR=/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/
export STAGING_DIR
./configure --build=x86_64-unknown-linux-gnu -host=mips-openwrt-linux-uclibc --prefix=/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr --disable-udev
make
make install

Now have USB support.

next up did the following for libgphoto2
PATH=$PATH:/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/
export PATH
STAGING_DIR=/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/
export STAGING_DIR
./configure --build=x86_64-unknown-linux-gnu -host=mips-openwrt-linux-uclibc --prefix=/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr LDFLAGS=-L/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr/lib
make
make install

All seems to complete fine.

Moved on to gphoto2 and used the same steps but fails for:
configure: error:
* Cannot autodetect popt.h
*
* Set POPT_CFLAGS and POPT_LIBS correctly.


looks like I need to find libpopt-dev but a task for another night.

If I were you, I would rather follow these instructions on how to setup a local OpenWRT trunk to compile from scratch. In this case, my preference is to use the git trunk, YMMV.

Ok down to the gphoto2 build now. But for some reason it keeps trying to link in my build machines libgphoto2.so located in /usr/local/lib/ instead of the one in the staging directory /home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr/lib/

Here is the exact error:
/bin/bash ../libtool  --tag=CC   --mode=link mips-openwrt-linux-uclibc-gcc -I.. -I../gphoto2 -I/usr/local/include/gphoto2  -DLOCALEDIR=\"/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr/share/locale\" -D_GPHOTO2_INTERNAL_CODE      -I/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr/include -g -O2 -Wall -Wmissing-declarations -Wmissing-prototypes -g  -g -o gphoto2   gphoto2-actions.o gphoto2-foreach.o gphoto2-gp-params.o gphoto2-spawnve.o gphoto2-main.o gphoto2-version.o gphoto2-range.o gphoto2-shell.o -L/usr/local/lib -lgphoto2 -lm -lgphoto2_port -lm     -lpthread    -L/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr/lib -lm
libtool: link: mips-openwrt-linux-uclibc-gcc -I.. -I../gphoto2 -I/usr/local/include/gphoto2 -DLOCALEDIR=\"/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr/share/locale\" -D_GPHOTO2_INTERNAL_CODE -I/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr/include -g -O2 -Wall -Wmissing-declarations -Wmissing-prototypes -g -g -o gphoto2 gphoto2-actions.o gphoto2-foreach.o gphoto2-gp-params.o gphoto2-spawnve.o gphoto2-main.o gphoto2-version.o gphoto2-range.o gphoto2-shell.o  -L/usr/local/lib /usr/local/lib/libgphoto2.so /usr/local/lib/libgphoto2_port.so /usr/lib/i386-linux-gnu/libltdl.so -ldl -lpthread -L/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr/lib -lm

/usr/local/lib/libgphoto2.so: could not read symbols: File in wrong format

collect2: error: ld returned 1 exit status



Anyone know the proper way to pass in that path to config?



I did set up a openwrt via git for BB. Don't want to use the trunk since it is not stable and already have a bunch of stuff set up on the router I don't want to redo.

ok some last minute progress. Got past that error by adding
--with-libgphoto2=/home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr/lib

But now failing
libtool: link: cannot find the library `/usr/local/lib/libltdl.la'
it exists in /home/wire/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/usr/lib

again it's like I missed some global flag to point all these requests at the proper set of libraries.

The discussion might have continued from here.