gcc - 如何为 GCC 链接 Libbluetooth?
问题描述
我正在尝试在我的 c 文件中使用 hci.h、hci_lib.h 等。将目标文件链接到 exec 的最终命令如下所示:
gcc -g3 -o execfile ./dev1.o ./dev2.o ./main.o ./nets.o `pkg-config --cflags --libs glib-2.0 gio-unix-2.0`
但是我收到这样的链接错误:
undefined reference to `hci_open_dev'
undefined reference to `hci_le_set_scan_parameters'
undefined reference to `hci_le_set_scan_enable'
undefined reference to `hci_le_set_scan_enable'
undefined reference to `hci_close_dev'
我知道这是因为我没有将 -lbluetooth 指定给 gcc。
有没有办法像我为上面的 glib 和 gio-unix 那样指定 libbluetooth-dev 到 pkg-config ?
解决方案
推荐阅读
- c# - 如何在操作系统窗口启动时始终以管理员权限启动 wpf 应用程序
- python - Py_BuildValue("y#", ...) 之后是否需要 PyBuffer_Release?
- java - 在 GoogleCredential 令牌请求中提供连接超时的 IP 是什么?
- sql - Redshift - Case 语句返回重复项
- python - 用于 RGB 图像的 graycomatrix
- jquery - 如何使用 Jquery 实现自动建议/完成框?
- scala - scalajs-react 路由器。如何在条件路由中执行 ajax 请求
- go - 如何在 Go 中迭代 []interface{}
- python - Pandas 中的并发进程数
- android - 程序类型已经存在:com.android.volley.BuildConfig