我正在尝试使用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_
方法,我都得到了奇怪的未定义引用。我怎么才能修好它?
发布于 2017-04-12 11:22:03
要将库libmodus与您的程序链接起来,您需要:
C/C++ general -> Paths and Symbols -> Includes -> GNU C++
C/C++ General -> Paths and Symbols -> Library Paths
C/C++ Build -> Settings -> Tool Settings -> GCC C++ Linker -> Libraries
你做到了(1.)和(2.)但你也需要做(3.)。
https://stackoverflow.com/questions/43367921
复制相似问题