【解决报错】解决蓝牙编程中遇到的undefined reference to `str2ba‘错误

报错


Bluetooth.c:(.text+0x80): undefined reference to `str2ba’
collect2: error: ld returned 1 exit status
: recipe for target ‘Bluetooth’ failed
make: *** [Bluetooth] Error 1

原因

str2ba函数属于bluetooth中的库函数,所以编译或者写make文件时的是时候需要额外链接该库,比如:

gcc -o Bluetooth Bluetooth.c -lbluetooth

链接该库之后,就不再报该错误

猜你喜欢

转载自blog.csdn.net/weixin_44517500/article/details/130932152