gpt4 book ai didi

C undefined reference - 不是名称修改

转载 作者:行者123 更新时间:2023-11-30 17:53:11 25 4
gpt4 key购买 nike

我有一个包含源文件的项目(每个 func 也有一个 .h):

  • test_functions.c
    • func1.c
    • func2.c
    • func3.c
    • func4.c
    • func5.c

我在 test_functions.c 中获取 func3.c 中定义的函数的 undefined reference 。

到目前为止的步骤:

  • make VERBOSE=1 显示构建 func3.c 和链接 func3.c.o
  • nm func3.c.o 显示符号已定义
  • readelf -s func3.c.o 显示符号也已定义
  • make VERBOSE=1 显示正在使用 gcc,而不是名称修改问题

这就是有趣的地方,我疯狂地删除了 func3.c 重新编译,现在我得到了对 func3 的 undefined reference (显然),现在也是一个 undefined reference 引用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'

最佳答案

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

关于C undefined reference - 不是名称修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15776172/

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