我在使用nvcc链接项目时遇到问题。它们与项目内定义的符号一起出现。我在cuda_bvh_constru.o文件中定义了一些函数符号。这是相关功能的nm输出:
nm cuda_bvh_constru.o | grep update
0000000000001376 t _ZN20BVHConstructionState14updateGeometryERK6float3S2_
0000000000000b70 t _ZN20BVHConstructionState19updateGeometry_wobbER6float3S1_
These symbols are need on the cuda_bvhexports.o file but always appears undefined:
nm cuda_bvhexports.o | grep update
U _ZN20BVHConstructionState14updateGeometryERK6float3S2_
U _ZN20BVHConstructionState19updateGeometry_wobbER6float3S1_
I'm using the eclipse IDE to make a CUDA project and the generated linking instruction with the relevants object files in bold is:
nvcc -L/usr/lib/llvm-2.8/lib -L/home/viniciusdasilva/NVIDIA_GPU_Computing_SDK/C/lib -L/home/viniciusdasilva/NVIDIA_GPU_Computing_SDK/C/common/lib/linux -L"/home/viniciusdasilva/workspace/CyberX3D/Debug" -L"/home/viniciusdasilva/workspace/PQP_v1.3/lib" -o "continuous_collision_detection" ./src/Matrix.o ./src/bvh_kernels.o ./src/cpu_bvh_constru.o **./src/cuda_bvh_constru.o** **./src/cuda_bvhexports.o** ./src/cuda_collision.o ./src/cuda_make_grid.o ./src/cuda_rss_constru.o ./src/cuda_timer.o ./src/cudasort.o ./src/geometry.o ./src/importer_utility.o ./src/lbvh.o ./src/lbvh2.o ./src/linux_functions.o ./src/main.o ./src/plyfile.o ./src/plyfunctions.o ./src/radixsort.o ./src/scene.o ./src/transform.o -lPQP -lcutil_x86_64 -lcudpp_x86_64 -lCyberX3D -lpthread -lrt -lGLEW -lboost_thread -lboost_serialization -lboost_wserialization -lboost_filesystem -lboost_system -lglut -ldl -lm -lLLVMTransformUtils -lLLVMipa -lLLVMSystem -lLLVMMC -lLLVMCore -lLLVMSupport -lLLVMAnalysis -lLLVMTarget -lLLVMAsmParser -lLLVMX86Disassembler -lLLVMInstCombine -lLLVMX86AsmParser -lLLVMX86AsmPrinter -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Info -lLLVMJIT -lLLVMExecutionEngine -lLLVMCodeGen -lLLVMScalarOpts -locelot
我无法弄清楚为什么链接器没有发现这些符号,因为我认为对象正在正确传递。我需要将这些对象放入特定的顺序吗?还是别的什么?
答案 0 :(得分:1)
订单必须是:
cuda_bvhexports.o cuda_bvh_constru.o
Why does the order in which libraries are linked sometimes cause errors in GCC?
答案 1 :(得分:0)
如果在cuda_bvh_constru.o前放置cuda_bvhexports.o不起作用,您可以尝试将所有目标文件放在静态库中,然后将其传递给链接器。