FreeModbus|FreeModbus LINUXTCP Compile ERROR

/********************************************************************************* *FreeModbus LINUXTCP Compile ERROR * 说明: *想使用FreeModbus TCP在Ubuntu上进行测试,结果其默认没有打开TCP功能。 * *2018-1-2 深圳 南山平山村 曾剑锋 ********************************************************************************/一、参考文档: 1. http://pl.comp.lang.c.narkive.com/3s8TevOZ/problem-z-kompilacj二、报错信息: /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/demo.c:76: undefined reference to `eMBTCPInit' ../../modbus/mb.o: In function `eMBInit': /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:148: undefined reference to `eMBRTUStart' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:149: undefined reference to `eMBRTUStop' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:150: undefined reference to `eMBRTUSend' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:151: undefined reference to `eMBRTUReceive' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:152: undefined reference to `vMBPortClose' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:153: undefined reference to `xMBRTUReceiveFSM' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:154: undefined reference to `xMBRTUTransmitFSM' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:155: undefined reference to `xMBRTUTimerT35Expired' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:157: undefined reference to `eMBRTUInit' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:162: undefined reference to `eMBASCIIStart' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:163: undefined reference to `eMBASCIIStop' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:164: undefined reference to `eMBASCIISend' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:165: undefined reference to `eMBASCIIReceive' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:166: undefined reference to `vMBPortClose' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:167: undefined reference to `xMBASCIIReceiveFSM' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:168: undefined reference to `xMBASCIITransmitFSM' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:169: undefined reference to `xMBASCIITimerT1SExpired' /home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP/../../modbus/mb.c:171: undefined reference to `eMBASCIIInit' collect2: error: ld returned 1 exit status Makefile:58: recipe for target 'tcpmodbus' failed make: *** [tcpmodbus] Error 1三、解决办法: 1. modified the file "freemodbus/modbus/include/mbconfig.h" 2. find the under code /*! \brief If Modbus ASCII support is enabled. */ #define MB_ASCII_ENABLED ( 1 ) /*! \brief If Modbus RTU support is enabled. */ #define MB_RTU_ENABLED ( 1 ) /*! \brief If Modbus TCP support is enabled. */ #define MB_TCP_ENABLED ( 0 ) /*! \brief The character timeout value for Modbus ASCII. change into #define MB_ASCII_ENABLED ( 0 ) #define MB_RTU_ENABLED ( 0 ) #define MB_TCP_ENABLED ( 1 )四、Compile Output: root@localhost:/home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP# make gcc -g -Wall -Iport -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp -pthread -o demo.o -c demo.c gcc -g -Wall -Iport -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp -pthread -o port/portother.o -c port/portother.c gcc -g -Wall -Iport -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp -pthread -o port/portevent.o -c port/portevent.c gcc -g -Wall -Iport -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp -pthread -o port/porttcp.o -c port/porttcp.c gcc -g -Wall -Iport -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp -pthread -o ../../modbus/mb.o -c ../../modbus/mb.c gcc -g -Wall -Iport -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp -pthread -o ../../modbus/tcp/mbtcp.o -c ../../modbus/tcp/mbtcp.c gcc -g -Wall -Iport -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp -pthread -o ../../modbus/functions/mbfunccoils.o -c ../../modbus/functions/mbfunccoils.c gcc -g -Wall -Iport -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp -pthread -o ../../modbus/functions/mbfuncdiag.o -c ../../modbus/functions/mbfuncdiag.c gcc -g -Wall -Iport -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp -pthread -o ../../modbus/functions/mbfuncholding.o -c ../../modbus/functions/mbfuncholding.c gcc -g -Wall -Iport -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp -pthread -o ../../modbus/functions/mbfuncinput.o -c ../../modbus/functions/mbfuncinput.c gcc -g -Wall -Iport -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp -pthread -o ../../modbus/functions/mbfuncother.o -c ../../modbus/functions/mbfuncother.c gcc -g -Wall -Iport -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp -pthread -o ../../modbus/functions/mbfuncdisc.o -c ../../modbus/functions/mbfuncdisc.c gcc -g -Wall -Iport -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp -pthread -o ../../modbus/functions/mbutils.o -c ../../modbus/functions/mbutils.c gcc demo.o port/portother.o port/portevent.o port/porttcp.o ../../modbus/mb.o ../../modbus/tcp/mbtcp.o ../../modbus/functions/mbfunccoils.o ../../modbus/functions/mbfuncdiag.o ../../modbus/functions/mbfuncholding.o ../../modbus/functions/mbfuncinput.o ../../modbus/functions/mbfuncother.o ../../modbus/functions/mbfuncdisc.o ../../modbus/functions/mbutils.o-lpthread-o tcpmodbus root@localhost:/home/zengjf/freemodbus/freemodbus-v1.5.0/demo/LINUXTCP#

【FreeModbus|FreeModbus LINUXTCP Compile ERROR】

    推荐阅读