gpt4 book ai didi

c - 针对库编译时出现“ undefined reference ”错误

转载 作者:行者123 更新时间:2023-11-30 16:19:04 24 4
gpt4 key购买 nike

我在代码中添加了第三方库,但在运行 make 时遇到这样的错误。请帮助我理解这个错误。

(.text+0x9b4): undefined reference to `snd_strerror'
/home/bet/Tent/tun/app/Common/hl/lib/libGHAL.a(gfxhal.o): In function `GFX_create_region':
/home/bet/Tent/tun/app/Common/hl/src/GHAL/gfxhal.c:1141: undefined reference to `my_key_handler'
/home/bet/Tent/tun/app/Common/hal/src/GHAL/gfxhal.c:1141: undefined reference to `create_window'
collect2: ld returned 1 exit status
make[2]: *** [all] Error 1
make[2]: Leaving directory `/home/bet/Tent/tun/app/Common/c_app'
make[1]: *** [ctv_all] Error 2
make[1]: Leaving directory `/home/bet/Tent/tun/app/Common'

最佳答案

这些是链接错误,它们告诉您链接器无法找到您正在使用的库的定义。
您必须将该库链接到您的项目。

gcc <your files for compilation> -lLibName

阅读 this 为了更好地理解。

关于c - 针对库编译时出现“ undefined reference ”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55711880/

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