Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


[C++] Can't compile libmtp
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

[C++] Can't compile libmtp

netomxnetomx Moderator, Veteran

Hi, can you help me? I cannot make this link work:

Reading specs from /home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/specs
COLLECT_GCC=arm-openwrt-linux-muslgnueabi-gcc.bin
COLLECT_LTO_WRAPPER=/home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../libexec/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/lto-wrapper
Target: arm-openwrt-linux-muslgnueabi
Configured with: /home/buildbot/slave/brcm2708/build/build_dir/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/gcc-5.3.0/configure --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt GCC 5.3.0 50078' --prefix=/home/buildbot/slave/brcm2708/build/staging_dir/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-openwrt-linux-muslgnueabi --with-gnu-ld --enable-target-optspace --disable-libgomp --disable-libmudflap --disable-multilib --disable-nls --without-isl --without-cloog --with-host-libstdcxx=-lstdc++ --with-gmp=/home/buildbot/slave/brcm2708/build/staging_dir/host --with-mpfr=/home/buildbot/slave/brcm2708/build/staging_dir/host --with-mpc=/home/buildbot/slave/brcm2708/build/staging_dir/host --disable-decimal-float --with-diagnostics-color=auto-if-env --disable-libssp --enable-__cxa_atexit --with-arch=armv6 --with-float=hard --with-headers=/home/buildbot/slave/brcm2708/build/staging_dir/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/include --disable-libsanitizer --enable-languages=c,c++ --enable-shared --enable-threads --with-slibdir=/home/buildbot/slave/brcm2708/build/staging_dir/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/lib --enable-lto --with-libelf=/home/buildbot/slave/brcm2708/build/staging_dir/host
Thread model: posix
gcc version 5.3.0 (OpenWrt GCC 5.3.0 50078)
COMPILER_PATH=/home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../libexec/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/:/home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../libexec/gcc/:/home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/../../../../arm-openwrt-linux-muslgnueabi/bin/
LIBRARY_PATH=/home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/:/home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../lib/gcc/:/home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/../../../../arm-openwrt-linux-muslgnueabi/lib/
COLLECT_GCC_OPTIONS='-g' '-O2' '-Wall' '-Wmissing-prototypes' '-o' '.libs/mtp-connect' '-v' '-march=armv6' '-mfloat-abi=hard' '-mtls-dialect=gnu'
 /home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../libexec/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/collect2 -plugin /home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../libexec/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/liblto_plugin.so -plugin-opt=/home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../libexec/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccyN92RZ.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -dynamic-linker /lib/ld-musl-armhf.so.1 -X -m armelf_linux_eabi -o .libs/mtp-connect /home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/../../../../arm-openwrt-linux-muslgnueabi/lib/crt1.o /home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/../../../../arm-openwrt-linux-muslgnueabi/lib/crti.o /home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/crtbegin.o -L /home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi//usr/lib -rpath-link /home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi//usr/lib -L/home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.3.0 -L/home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../lib/gcc -L/home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/../../../../arm-openwrt-linux-muslgnueabi/lib connect.o delfile.o getfile.o newfolder.o sendfile.o sendtr.o pathutils.o util.o ../src/.libs/libmtp.so -lusb-1.0 -lssp_nonshared -lgcc_s -lc -lgcc_s /home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/crtend.o /home/netomx/rpi0/OpenWrt-Toolchain-brcm2708-bcm2708_gcc-5.3.0_musl-1.1.16_eabi.Linux-x86_64/toolchain-arm_arm1176jzf-s+vfp_gcc-5.3.0_musl-1.1.16_eabi/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.3.0/../../../../arm-openwrt-linux-muslgnueabi/lib/crtn.o
../src/.libs/libmtp.so: undefined reference to `libusb_release_interface'
../src/.libs/libmtp.so: undefined reference to `libusb_get_device_descriptor'
../src/.libs/libmtp.so: undefined reference to `libusb_control_transfer'
../src/.libs/libmtp.so: undefined reference to `libusb_claim_interface'
../src/.libs/libmtp.so: undefined reference to `libusb_close'
../src/.libs/libmtp.so: undefined reference to `libusb_get_device_address'
../src/.libs/libmtp.so: undefined reference to `libusb_kernel_driver_active'
../src/.libs/libmtp.so: undefined reference to `libusb_set_debug'
../src/.libs/libmtp.so: undefined reference to `libusb_detach_kernel_driver'
../src/.libs/libmtp.so: undefined reference to `libusb_get_config_descriptor'
../src/.libs/libmtp.so: undefined reference to `libusb_free_device_list'
../src/.libs/libmtp.so: undefined reference to `libusb_reset_device'
../src/.libs/libmtp.so: undefined reference to `libusb_get_device_list'
../src/.libs/libmtp.so: undefined reference to `libusb_set_interface_alt_setting'
../src/.libs/libmtp.so: undefined reference to `libusb_get_device'
../src/.libs/libmtp.so: undefined reference to `libusb_free_config_descriptor'
../src/.libs/libmtp.so: undefined reference to `libusb_clear_halt'
../src/.libs/libmtp.so: undefined reference to `libusb_bulk_transfer'
../src/.libs/libmtp.so: undefined reference to `libusb_get_string_descriptor_ascii'
../src/.libs/libmtp.so: undefined reference to `libusb_init'
../src/.libs/libmtp.so: undefined reference to `libusb_get_bus_number'
../src/.libs/libmtp.so: undefined reference to `libusb_open'
collect2: error: ld returned 1 exit status

Any ideas? Thanks

Comments

  • You need to link in libusb. Do ldd ../src/.libs/libmtp.so to figure out where it is (-lusb-1.0 may need an additional path with -L).

  • netomxnetomx Moderator, Veteran

    @rincewind said:
    You need to link in libusb. Do ldd ../src/.libs/libmtp.so to figure out where it is (-lusb-1.0 may need an additional path with -L).

    netomx@debian:~/rpi0/libmtp-1.1.4/examples$ file ../src/.libs/libmtp.so
    ../src/.libs/libmtp.so: symbolic link to libmtp.so.9.0.4
    
    netomx@debian:~/rpi0/libmtp-1.1.4/examples$ file ../src/.libs/libmtp.so.9.0.4
    ../src/.libs/libmtp.so.9.0.4: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, not stripped
    
    netomx@debian:~/rpi0/libmtp-1.1.4/examples$ ldd ../src/.libs/libmtp.so.9.0.4
            not a dynamic executable
    
  • netomxnetomx Moderator, Veteran

    If I use the cross-compile "readelf"

    http://pastebin.com/i2v5Rmt8

  • The hint wasn't bad per se but it couldn't work as libsmtp wasn't properly built in the first place due to libusb missing.

    Try a simple find /usr/lib -name 'libusb*' and append (with -L) the path where it's found and -lusb (or -lusb-1 or what ever it's called in your distro) and then the build should work.

  • WSSWSS Member

    Being that this is cross-compiled, I doubt that all of the prerequisites are actually being met. Make sure your build configuration is actually good for your OWRT destination..

  • netomx said: If I use the cross-compile "readelf"

    http://pastebin.com/i2v5Rmt8

    The readelf output shows the link to libusb-1 so the file should be around somewhere in your build. Search in ../src/.libs/ or find /home/netomx/rpi0/ -name 'libusb-1.0.so'.

  • netomxnetomx Moderator, Veteran
    edited January 2017

    @rincewind said:

    netomx said: If I use the cross-compile "readelf"

    http://pastebin.com/i2v5Rmt8

    The readelf output shows the link to libusb-1 so the file should be around somewhere in your build. Search in ../src/.libs/ or find /home/netomx/rpi0/ -name 'libusb-1.0.so'.

    I place it on the same dir as the compilation. It should work, isn't it?

    EDIT: copied to ../src/.libs and nope, not working :(

  • netomx said: I place it on the same dir as the compilation. It should work, isn't it?

    Add -L ../src/.libs to your compiler flags, just before -lusb-1.0. Placing in the same directory as compilation does not make a difference - you need to explicitly add it to library search path.

  • netomxnetomx Moderator, Veteran

    @rincewind said:

    netomx said: I place it on the same dir as the compilation. It should work, isn't it?

    Add -L ../src/.libs to your compiler flags, just before -lusb-1.0. Placing in the same directory as compilation does not make a difference - you need to explicitly add it to library search path.

    Already tried it:

    netomx@debian:~/rpi0/libmtp-1.1.4/examples$ arm-openwrt-linux-muslgnueabi-gcc -g -O2 -Wall -Wmissing-prototypes -o .libs/mtp-connect connect.o delfile.o getfile.o newfolder.o sendfile.o sendtr.o pathutils.o util.o  ../src/.libs/libmtp.so -L../src/.libs -lusb-1.0
    ../src/.libs/libmtp.so: undefined reference to `libusb_release_interface'
    ../src/.libs/libmtp.so: undefined reference to `libusb_get_device_descriptor'
    ../src/.libs/libmtp.so: undefined reference to `libusb_control_transfer'
    ../src/.libs/libmtp.so: undefined reference to `libusb_claim_interface'
    ../src/.libs/libmtp.so: undefined reference to `libusb_close'
    ../src/.libs/libmtp.so: undefined reference to `libusb_get_device_address'
    ../src/.libs/libmtp.so: undefined reference to `libusb_kernel_driver_active'
    ../src/.libs/libmtp.so: undefined reference to `libusb_set_debug'
    ../src/.libs/libmtp.so: undefined reference to `libusb_detach_kernel_driver'
    ../src/.libs/libmtp.so: undefined reference to `libusb_get_config_descriptor'
    ../src/.libs/libmtp.so: undefined reference to `libusb_free_device_list'
    ../src/.libs/libmtp.so: undefined reference to `libusb_reset_device'
    ../src/.libs/libmtp.so: undefined reference to `libusb_get_device_list'
    ../src/.libs/libmtp.so: undefined reference to `libusb_set_interface_alt_setting'
    ../src/.libs/libmtp.so: undefined reference to `libusb_get_device'
    ../src/.libs/libmtp.so: undefined reference to `libusb_free_config_descriptor'
    ../src/.libs/libmtp.so: undefined reference to `libusb_clear_halt'
    ../src/.libs/libmtp.so: undefined reference to `libusb_bulk_transfer'
    ../src/.libs/libmtp.so: undefined reference to `libusb_get_string_descriptor_ascii'
    ../src/.libs/libmtp.so: undefined reference to `libusb_init'
    ../src/.libs/libmtp.so: undefined reference to `libusb_get_bus_number'
    ../src/.libs/libmtp.so: undefined reference to `libusb_open'
    collect2: error: ld returned 1 exit status
    
    
  • It expects a libusb-1.0.so in ../src/.libs. Are you sure that is the filename, and not libusb.so?

    Maybe it is picking up a wrong file from somewhere else, possibly your LIBRARY_PATH has a corrupted libusb.

    You could do an 'strace' on the gcc, log to a file, and scan it for libusb - but that is overkill.

  • apt-get install libusb-dev ?

  • netomxnetomx Moderator, Veteran

    @rincewind said:
    It expects a libusb-1.0.so in ../src/.libs. Are you sure that is the filename, and not libusb.so?

    Maybe it is picking up a wrong file from somewhere else, possibly your LIBRARY_PATH has a corrupted libusb.

    You could do an 'strace' on the gcc, log to a file, and scan it for libusb - but that is overkill.

    LOL, let me tell you what it WAS:

    I was using the wrong libusb lib :$

    Compile Openwrt, got the libusb from there, and compiled :)

  • netomxnetomx Moderator, Veteran

    @willie said:
    apt-get install libusb-dev ?

    OpenWRT, dude.

  • netomx said: LOL, let me tell you what it WAS:

    I was using the wrong libusb lib :$

    Lol. BTW, OpenWRT has opkg install ...

  • netomxnetomx Moderator, Veteran

    @rincewind said:

    netomx said: LOL, let me tell you what it WAS:

    I was using the wrong libusb lib :$

    Lol. BTW, OpenWRT has opkg install ...

    That comment was for willie, right?

  • netomx said: That comment

    My bad. Didn't realize how limited the OpenWrt repos were. I've only used OpenWare on an old NSLU2 where the repos were far more comprehensive.

Sign In or Register to comment.