我正在尝试将 libusb-1.0 库与Nsight Eclipse一起使用。我按照以下步骤进行操作:
- 下载 libusb-1.0 压缩包并安装在主机(Ubuntu)中。
按照 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'
我添加了以下内容:
- 'LIBDIR' 和 libusb.-1.0.so 菜单下的文件路径 Tool -> Settings -> NVCC Linker -> Libraries -> Library search path(-L)
- LD_LIBRARY_PATH 和 LD_RUN_PATH 环境变量
- NVCC编译器下的libusb.h路径->包含->包含路径(-l)
- -lusb-1.0 在 NVCC Linker -> Miscellaneous -> Other flag 下
当我在 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
我该如何解决?