gpt4 book ai didi

c++ - 对本地对象的 undefined reference

转载 作者:行者123 更新时间:2023-11-28 08:20:24 25 4
gpt4 key购买 nike

我在使用 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 

Why does the order in which libraries are linked sometimes cause errors in GCC?

关于c++ - 对本地对象的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6020323/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com