0

我有一个带有源文件的项目(每个函数也有一个.h):

  • test_functions.c
    • 函数1.c
    • 函数2.c
    • 函数3.c
    • func4.c
    • func5.c

我得到一个未定义的引用,test_functions.c用于func3.c.

到目前为止的步骤:

  • make VERBOSE=1显示 func3.c 的构建和 func3.co 的链接
  • 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'
4

1 回答 1

0

这是经典的 PEBCAK。如果您仔细查看编译行,就会发现rplink-path它后面没有路径。我猜 gcc 链接器将下一个目标文件作为参数附加到rplink-path.

于 2013-04-04T18:55:31.457 回答