我有一个包含源文件的项目(每个func也有一个.h):
我在test_functions.c
中为func3.c
中定义的函数获取了未定义的引用。
到目前为止的步骤:
make VERBOSE=1
显示构建func3.c并链接func3.c.o nm func3.c.o
显示符号已定义readelf -s func3.c.o
显示符号也已定义make VERBOSE=1
显示正在使用gcc,而不是名称重整问题这里有趣的地方,我狂野地移除了func3.c
重新编译,现在我得到了func3
的明确引用(显然),现在也是对func2
的未定义引用! !但是我之前已经用这个函数编译过了!
如果我将func3.c
添加回来源,请将功能调用注释为func3()
我可以致电func2()
就好......我完全失去了。
请求编译:
Scanning dependencies of target test_opencl_functions
make[2]: Leaving directory `/home/constantin/workspace/durp/tests/release_arm'
make -f CMakeFiles/test_opencl_functions.dir/build.make CMakeFiles/test_opencl_functions.dir/build
make[2]: Entering directory `/home/constantin/workspace/durp/tests/release_arm'
/usr/bin/cmake -E cmake_progress_report /home/constantin/workspace/durp/tests/release_arm/CMakeFiles 14
[ 53%] Building C object CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclpyramid.c.o
/usr/bin/arm-linux-gnueabi-gcc-4.5 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -I/home/constantin/workspace/durp/tests/../PanasonicCameraLib -I/home/constantin/workspace/durp/tests/../linux_arm_tool/include -o CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclpyramid.c.o -c /home/constantin/workspace/durp/tests/src/opencl/opencl_functions/openclpyramid.c
/usr/bin/cmake -E cmake_progress_report /home/constantin/workspace/durp/tests/release_arm/CMakeFiles 15
[ 57%] Building C object CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclimagewarp.c.o
/usr/bin/arm-linux-gnueabi-gcc-4.5 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -I/home/constantin/workspace/durp/tests/../PanasonicCameraLib -I/home/constantin/workspace/durp/tests/../linux_arm_tool/include -o CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclimagewarp.c.o -c /home/constantin/workspace/durp/tests/src/opencl/opencl_functions/openclimagewarp.c
/usr/bin/cmake -E cmake_progress_report /home/constantin/workspace/durp/tests/release_arm/CMakeFiles 16
[ 61%] Building C object CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/opencl_utilities.c.o
/usr/bin/arm-linux-gnueabi-gcc-4.5 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -I/home/constantin/workspace/durp/tests/../PanasonicCameraLib -I/home/constantin/workspace/durp/tests/../linux_arm_tool/include -o CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/opencl_utilities.c.o -c /home/constantin/workspace/durp/tests/src/opencl/opencl_functions/opencl_utilities.c
/usr/bin/cmake -E cmake_progress_report /home/constantin/workspace/durp/tests/release_arm/CMakeFiles 17
[ 65%] Building C object CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclbackgroundsub.c.o
/usr/bin/arm-linux-gnueabi-gcc-4.5 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -I/home/constantin/workspace/durp/tests/../PanasonicCameraLib -I/home/constantin/workspace/durp/tests/../linux_arm_tool/include -o CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclbackgroundsub.c.o -c /home/constantin/workspace/durp/tests/src/opencl/opencl_functions/openclbackgroundsub.c
/usr/bin/cmake -E cmake_progress_report /home/constantin/workspace/durp/tests/release_arm/CMakeFiles 18
[ 69%] Building C object CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclconvolution.c.o
/usr/bin/arm-linux-gnueabi-gcc-4.5 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -I/home/constantin/workspace/durp/tests/../PanasonicCameraLib -I/home/constantin/workspace/durp/tests/../linux_arm_tool/include -o CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclconvolution.c.o -c /home/constantin/workspace/durp/tests/src/opencl/opencl_functions/openclconvolution.c
/usr/bin/cmake -E cmake_progress_report /home/constantin/workspace/durp/tests/release_arm/CMakeFiles 19
[ 73%] Building C object CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclrgbtogray.c.o
/usr/bin/arm-linux-gnueabi-gcc-4.5 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -I/home/constantin/workspace/durp/tests/../PanasonicCameraLib -I/home/constantin/workspace/durp/tests/../linux_arm_tool/include -o CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclrgbtogray.c.o -c /home/constantin/workspace/durp/tests/src/opencl/opencl_functions/openclrgbtogray.c
/usr/bin/cmake -E cmake_progress_report /home/constantin/workspace/durp/tests/release_arm/CMakeFiles 20
[ 76%] Building C object CMakeFiles/test_opencl_functions.dir/src/opencl/test_functions.c.o
/usr/bin/arm-linux-gnueabi-gcc-4.5 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -I/home/constantin/workspace/durp/tests/../PanasonicCameraLib -I/home/constantin/workspace/durp/tests/../linux_arm_tool/include -o CMakeFiles/test_opencl_functions.dir/src/opencl/test_functions.c.o -c /home/constantin/workspace/durp/tests/src/opencl/test_functions.c
Linking C executable test_opencl_functions
/usr/bin/cmake -E cmake_link_script CMakeFiles/test_opencl_functions.dir/link.txt --verbose=1
/usr/bin/arm-linux-gnueabi-gcc-4.5 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -mfpu=vfpv3-d16 -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-z,nocopyreloc -Wl,-rpath-link,/home/constantin/workspace/durp/tests/../linux_arm_tool/lib,-rpath-link,/usr/arm-linux-gnueabi/lib,-rpath-link CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclpyramid.c.o CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclimagewarp.c.o CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/opencl_utilities.c.o CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclbackgroundsub.c.o CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclconvolution.c.o CMakeFiles/test_opencl_functions.dir/src/opencl/opencl_functions/openclrgbtogray.c.o CMakeFiles/test_opencl_functions.dir/src/opencl/test_functions.c.o -o test_opencl_functions -L/home/constantin/workspace/durp/tests/../linux_arm_tool/lib -L/home/constantin/workspace/durp/CarmaDev/cuda/lib -rdynamic -lPanasonicCameraLib -lm -lOpenCL -lGAL
CMakeFiles/test_opencl_functions.dir/src/opencl/test_functions.c.o: In function `TestPyramid':
test_functions.c:(.text+0x89c): undefined reference to `opencl_pyramid'
答案 0 :(得分:0)
这是经典的PEBCAK。如果你仔细查看编译行,那么rplink-path
后面没有路径。我猜gcc链接器将下一个目标文件作为rplink-path
的参数附加。