Linking libusb-1.0 library in Nsight Eclipse?

1k Views Asked by At

I'm trying to use libusb-1.0 library with Nsight Eclipse. I followed the following steps to do it:

  1. Downloaded the libusb-1.0 tarball and installed in the host (Ubuntu).
  2. As per instructions given at the end of libusb installation:

    Libraries have been installed in:
        /usr/local/lib
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
    
      - Add LIBDIR to the `LD_LIBRARY_PATH' environment variable
    
    During execution:
    
      - Add LIBDIR to the `LD_RUN_PATH' environment variable
    
    During linking:
    
      - Use the `-Wl,-rpath -Wl,LIBDIR' linker flag
      - Have your system administrator add LIBDIR to `/etc/ld.so.conf'
    

I added the following:

  • 'LIBDIR' and libusb.-1.0.so file path under menu Tool -> Settings -> NVCC Linker -> Libraries -> Library search path(-L)
  • LD_LIBRARY_PATH and LD_RUN_PATH environment variables
  • libusb.h path under NVCC Compiler -> Includes -> Include paths(-l)
  • -lusb-1.0 under NVCC Linker -> Miscellaneous -> Other flag

When I build my project in Nsight Eclipse, I get the following error in the console.

make all

Building file: ../src/sample.cu
Invoking: NVCC Compiler
/usr/local/cuda-6.5/bin/nvcc -I/usr/include/libusb-1.0 -G -g -O0 -ccbin arm-linux-gnueabihf-g++-4.6 -gencode arch=compute_20,code=sm_20 --target-cpu-architecture ARM -m32 -odir "src" -M -o "src/sample.d" "../src/sample.cu"
/usr/local/cuda-6.5/bin/nvcc -I/usr/include/libusb-1.0 -G -g -O0 --compile --relocatable-device-code=false -gencode arch=compute_20,code=compute_20 -gencode arch=compute_20,code=sm_20 --target-cpu-architecture ARM -m32 -ccbin arm-linux-gnueabihf-g++-4.6  -x cu -o  "src/sample.o" "../src/sample.cu"
../src/sample.cu(71): warning: variable "data" was declared but never referenced

../src/sample.cu(71): warning: variable "data" was declared but never referenced

Finished building: ../src/sample.cu

Building target: sample
Invoking: NVCC Linker
/usr/local/cuda-6.5/bin/nvcc --cudart static -LLIBDIR -Xlinker --unresolved-symbols=ignore-in-shared-libs --relocatable-device-code=false -gencode arch=compute_20,code=compute_20 -gencode arch=compute_20,code=sm_20 --target-cpu-architecture ARM -m32 -ccbin arm-linux-gnueabihf-g++-4.6 -link -o  "sample"  ./src/sample.o  -lusb-1.0
/usr/lib/../lib/libusb-1.0.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make: *** [sample] Error 1

How do I fix this?

1

There are 1 best solutions below

0
On

I was able to fix my problem with the help of libusb development mailing list. libusb library was supposed to be configured for the target on 64bit host machine.

I had to configure library for target arm-linux-gnueabihf and i had to disable udev. So, I used the command,

./configure --host=arm-linux-gnueabihf --prefix=/usr --disable-static --disable-udev && make && make install

I was able to configure libusb properly and it compiles now.