【问题标题】:cmake give undefined referencecmake给出未定义的参考
【发布时间】:2014-09-20 22:00:04
【问题描述】:

您好,我正在尝试使用 bluez 源代码来控制我的代码中的一些内容。

在我的 cmake 中,我首先开始做类似

的指令
include_directories(${CMAKE_SOURCE_DIR}/../bluez/attrib/)

然后

aux_source_directory(${CMAKE_SOURCE_DIR}/../bluez/attrib/ SRC_BLUEZ_ATTRIB_LIST)

最后将SRC_BLUEZ_ATTRIB_LIST 添加到我的add_executable

但我还有

undefined reference to gatt_connect(char const*, char const*, char const*, char const*, int, int, void (*)(_GIOChannel*, _GError*, void*), _GError**)

有什么建议吗?

【问题讨论】:

  • SRC_BLUEZ_ATTRIB_LIST(MESSAGE(${SRC_BLUEZ_ATTRIB_LIST}))的内容是什么?
  • bluez source 中 attrib 文件夹中的源文件路径
  • 他们定义了gatt_connect符号?
  • 是的,它在 utils.c 中定义,并显示在 MESSAGE(${SRC_BLUEZ_ATTRIB_LIST}) 的结果中
  • 在哪个标头中声明?你的源代码是c++?

标签: c++ cmake bluez


【解决方案1】:

在您的c++ 源文件中使用extern "C"

extern "C" {
   #include "gatttool.h"
}

【讨论】:

    猜你喜欢
    • 2017-10-13
    • 2015-09-14
    • 2016-07-01
    • 1970-01-01
    • 2010-10-19
    • 1970-01-01
    • 1970-01-01
    • 2012-10-17
    • 1970-01-01
    相关资源
    最近更新 更多