在Nsight Eclipse中链接libusb-1.0库?

时间:2014-12-20 01:45:28

标签: linux eclipse linker-errors nsight libusb-1.0

我试图将libusb-1.0库与Nsight Eclipse一起使用。我按照以下步骤进行操作:

  1. 下载了libusb-1.0 tarball并安装在主机(Ubuntu)中。
  2. 根据libusb安装结束时的说明:

    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'
    
  3. 我添加了以下内容:

    • ' LIBDIR'和菜单工具下的libusb.-1.0.so文件路径 - >设置 - > NVCC Linker - >图书馆 - >图书馆搜索路径(-L)
    • LD_LIBRARY_PATH和LD_RUN_PATH环境变量
    • NVCC编译器下的libusb.h路径 - >包括 - >包含路径(-l)
    • NVCC Linker下的
    • -lusb-1.0 - >其他 - >其他旗帜

    当我在Nsight Eclipse中构建项目时,我在控制台中收到以下错误。

    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
    

    我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

我能够在libusb开发邮件列表的帮助下修复我的问题。 应该在64位主机上为目标配置libusb库。

我必须为目标arm-linux-gnueabihf配置库,我必须禁用udev。 所以,我使用了命令

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

我能够正确配置libusb并立即编译。