繁体   English   中英

Eclipse C ++未定义参考

[英]Eclipse C++ undefined reference

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

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_方法的奇怪的未定义参考。 我该如何解决?

为了使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.)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM