首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Eclipse C++未定义引用

Eclipse C++未定义引用
EN

Stack Overflow用户
提问于 2017-04-12 11:10:50
回答 1查看 3.8K关注 0票数 0

我正在尝试使用libmodbus,我有以下内容:

代码语言:javascript
运行
复制
extern "C" {
#include "modbus.h"
#include "modbus-tcp.h"
}

void executeMbus() {
    modbus_t *mb;
    uint16_t tab_reg[32];
    mb = modbus_new_tcp("127.0.0.1", 1502);
    modbus_connect(mb);

    /* Read 5 registers from the address 0 */
    modbus_read_registers(mb, 0, 5, tab_reg);

    modbus_close(mb);
    modbus_free(mb);
}

我在C/C++ General -> Paths and Symbols GNU C++中将路径添加到库中,并将路径添加到modbus库中。但是,对于每个modbus_方法,我都得到了奇怪的未定义引用。我怎么才能修好它?

EN

回答 1

Stack Overflow用户

发布于 2017-04-12 11:22:03

要将库libmodus与您的程序链接起来,您需要:

  1. 将包含路径添加到编译器设置C/C++ general -> Paths and Symbols -> Includes -> GNU C++
  2. 将库路径添加到链接器设置C/C++ General -> Paths and Symbols -> Library Paths
  3. 将库对象添加到链接器设置C/C++ Build -> Settings -> Tool Settings -> GCC C++ Linker -> Libraries

你做到了(1.)和(2.)但你也需要做(3.)。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43367921

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档