针对库编译时出现“未定义引用"错误 [英] 'undefined reference' errors when compiling against library

查看:49
本文介绍了针对库编译时出现“未定义引用"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I added a third party library to my code and is getting errors like this when running make. Please help me understand this error.

(.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'

推荐答案

那些是链接错误,告诉您链接器找不到您正在使用的库的定义.
您必须将库链接到您的项目.

Those are Linking errors, which tell you the linker cannot find definitions for the library you are using.
You will have to link the library to your project.

gcc <your files for compilation> -lLibName

阅读this更好的理解.

Read this for better understanding.

这篇关于针对库编译时出现“未定义引用"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆