Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/145.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 对本地对象的未定义引用_C++_Cuda_Undefined Reference_Nvcc - Fatal编程技术网

C++ 对本地对象的未定义引用

C++ 对本地对象的未定义引用,c++,cuda,undefined-reference,nvcc,C++,Cuda,Undefined Reference,Nvcc,我在使用nvcc链接项目时遇到问题。它们与项目内部定义的符号一起出现。我在cuda_bvh_constru.o文件中定义了一些函数符号。这是相关功能的nm输出: nm cuda_bvh_constru.o | grep update 0000000000001376 t _ZN20BVHConstructionState14updateGeometryERK6float3S2_ 0000000000000b70 t _ZN20BVHConstructionState19updateGeometr

我在使用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
我不明白为什么链接器没有发现这些符号,因为我认为这些对象是正确传递的。我需要把这些东西按特定的顺序摆放吗?还是其他原因?

顺序必须是:

cuda_bvhexports.o cuda_bvh_constru.o 

如果将cuda_bvhexports.o放在cuda_bvh_constru.o前面不起作用,您可以尝试将所有对象文件放在静态库中,然后将其传递给链接器