Author Topic: cross compile libusb for arm  (Read 9103 times)

powerboy2988

  • Member
  • ***
  • Posts: 5
cross compile libusb for arm
« on: April 03, 2016, 03:24:04 am »
Hi,, i have a problem with cross compile libusb :

settings :
Code: [Select]
 
  export STAGING=$HOME/out
  export HOST=arm-linux
  CROSS_COMPILE=arm-none-linux-gnueabi-
  CC=/home/hossein/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc

I did download libusb source from https://git.libusb.org/libusb.git , i did ./configure --host=$HOST --prefix=$STAGING & make & sudo make install

.

But in hidapi when i want make i get this error :
Code: [Select]

make[2]: Entering directory `/home/hossein/hidTest/hidapi/hidtest'
  CXXLD    hidtest-libusb
../libusb/.libs/libhidapi-libusb.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
make[2]: *** [hidtest-libusb] Error 1
make[2]: Leaving directory `/home/hossein/hidTest/hidapi/hidtest'



In checked /home/hossein/hidTest/hidapi/libusb/.libs/libhidapi-libusb.la that the link directory was correct :

Code: [Select]
# The name that we can dlopen(3).
dlname='libusb.so'

# Names of this library.
library_names='libusb.so'

# The name of the static archive.
old_library='libusb.a'

# Linker flags that can not go in dependency_libs.
inherited_linker_flags=' -pthread'

# Libraries that this one depends upon.
dependency_libs=' -L/home/hossein/out/lib /home/hossein/out/lib/libusb-1.0.la -lrt'


Now i confused why i got that problem! ..


- did I download wrong libusb ?


Thanks

Hossein
« Last Edit: April 03, 2016, 04:08:33 am by powerboy2988 »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: cross compile libusb for arm
« Reply #1 on: April 03, 2016, 10:11:15 am »
If you search the web on:

libusb error adding symbols: File in wrong format

you will find various reasons for and possible solutions for this error.

For example:

http://www.edaboard.com/thread256758.html

http://libusb.6.n5.nabble.com/Cross-Compilig-Issue-for-MIPS-Little-Endain-Architecture-td4872500.html


powerboy2988

  • Member
  • ***
  • Posts: 5
Re: cross compile libusb for arm
« Reply #2 on: April 06, 2016, 04:59:09 am »
Thanks :)
Sorry for my persecute

Finally i could cross compile without any error, i following these commands :

mkdir hid
cd hid

git clone git://git.libusb.org/libusb.git
git clone git://github.com/signal11/hidapi.git
git clone https://github.com/gentoo/eudev.git

export STAGING=$HOME/out
export HOST=arm-linux
CROSS_COMPILE=arm-none-linux-gnueabi-
CXX=/home/hossein/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-g++
CC=/home/hossein/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc
export CC CROSS_COMPILE

cd libusb

./configure --host=$HOST --prefix=$STAGING
make
sudo make install

cd ../eudev

./configure --disable-gudev --disable-introspection --disable-hwdb  --host=$HOST --prefix=$STAGING

make
sudo make install


cd ../hidapi

./bootstrap

PKG_CONFIG_DIR= PKG_CONFIG_LIBDIR=$STAGING/lib/pkgconfig:$STAGING/share/pkgconfig PKG_CONFIG_SYSROOT_DIR=$STAGING ./configure --host=$HOST --prefix=$STAGING

make

sudo make install


/////


But when i compile in Qt, i get these errors :


hossein@hossein-laptop:~/hid/hidapi/hidtest$ arm-linux-gnueabihf-g++ hidtest.cpp -o myTest
/tmp/ccX4fi6L.o: In function `main':
hidtest.cpp:(.text+0x14): undefined reference to `hid_init'
hidtest.cpp:(.text+0x44): undefined reference to `hid_enumerate'
hidtest.cpp:(.text+0x11c): undefined reference to `hid_free_enumeration'
hidtest.cpp:(.text+0x154): undefined reference to `hid_open'
hidtest.cpp:(.text+0x198): undefined reference to `hid_get_manufacturer_string'
hidtest.cpp:(.text+0x1e8): undefined reference to `hid_get_product_string'
hidtest.cpp:(.text+0x238): undefined reference to `hid_get_serial_number_string'
hidtest.cpp:(.text+0x29c): undefined reference to `hid_get_indexed_string'
hidtest.cpp:(.text+0x2d8): undefined reference to `hid_set_nonblocking'
hidtest.cpp:(.text+0x2f0): undefined reference to `hid_read'
hidtest.cpp:(.text+0x338): undefined reference to `hid_send_feature_report'
hidtest.cpp:(.text+0x38c): undefined reference to `hid_get_feature_report'
hidtest.cpp:(.text+0x3b0): undefined reference to `hid_error'
hidtest.cpp:(.text+0x470): undefined reference to `hid_write'
hidtest.cpp:(.text+0x494): undefined reference to `hid_error'
hidtest.cpp:(.text+0x4cc): undefined reference to `hid_write'
hidtest.cpp:(.text+0x504): undefined reference to `hid_read'
hidtest.cpp:(.text+0x5cc): undefined reference to `hid_close'
hidtest.cpp:(.text+0x5d0): undefined reference to `hid_exit'

...

I dont know what can i do for solve these errors , i searching a lot in web and read a lot of web pages and documents, but i cant do anything...


Thanks a lot

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: cross compile libusb for arm
« Reply #3 on: April 06, 2016, 12:09:30 pm »
I am not a Qt expert. You might have more luck asking here:

https://forum.qt.io

or

http://www.qtforum.org

powerboy2988

  • Member
  • ***
  • Posts: 5
Re: cross compile libusb for arm
« Reply #4 on: April 07, 2016, 05:24:47 am »
Thanks i can cross compile hidapi from commadline ,, but those errors still exist in qt .

this link is my solution : https://www.raspberrypi.org/forums/viewtopic.php?f=33&t=143377

Thanks a lot

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: cross compile libusb for arm
« Reply #5 on: April 07, 2016, 09:59:01 am »
It looks like you are making good progress! I'm glad you found a site with some answers. Thanks for reporting back.

powerboy2988

  • Member
  • ***
  • Posts: 5
Re: cross compile libusb for arm
« Reply #6 on: April 08, 2016, 02:23:39 am »
Your welcome ..  ;)