1 Reply Latest reply on Mar 7, 2016 4:36 PM by drp-WindRiver

    Compile errors when using lwIP netconn API

    wini

      I followed your lwIP instructions and I was able to successfully compile the lwIP HTTP example. I then went on to adding our open source SMQ version and example, which can be downloaded from:

      https://realtimelogic.com/products/simplemq/src/

       

      I removed all the other porting layers and only included the lwIP netconn porting layer. I made some minor modifications to the makefile and I then tried to compile. This failed as the lwIP version you have does not appear to be a standard one. I have included some of the compiler errors below. I have exported the project from your IDE (including SMQ) and uploaded the project to our server:

       

      https://realtimelogic.info/tmp/HTTP-Server.tar.gz

       

      I have previously compiled this code for the mbed platform using the online mbed IDE and tested the code on an mbed board. The mbed IDE appears to be similar to your IDE.

       

      Here's a snapshot of the errors I got. The first error is from err_t, which should be part of a standard lwIP release:

      http://rtl-lwip.sourceforge.net/sources/err_8h.html

       

       

      ../src/../SimpleMQ/src/seLwIP.c: In function 'se_accept':

      ../src/../SimpleMQ/src/seLwIP.c:60:4: error: unknown type name 'err_t'

          err_t err;

          ^

      ../src/../SimpleMQ/src/seLwIP.c:52:11: error: dereferencing pointer to incomplete type

          ((conn)->recv_timeout = (timeout))

                 ^

      ../src/../SimpleMQ/src/seLwIP.c:62:4: note: in expansion of macro 'netconn_set_recvtimeout'

          netconn_set_recvtimeout(

          ^

      ../src/../SimpleMQ/src/seLwIP.c:65:4: warning: implicit declaration of function 'netconn_accept' [-Wimplicit-function-declaration]

          (*outSock)->con = netconn_accept((*listenSock)->con);

          ^

      ../src/../SimpleMQ/src/seLwIP.c:65:20: warning: assignment makes pointer from integer without a cast [enabled by default]

          (*outSock)->con = netconn_accept((*listenSock)->con);

                          ^

      ../src/../SimpleMQ/src/seLwIP.c:66:25: error: dereferencing pointer to incomplete type

          err = (*outSock)->con->err;

                               ^

      ../src/../SimpleMQ/src/seLwIP.c:67:39: error: 'ERR_CONN' undeclared (first use in this function)

          if(!(*outSock)->con && !err) err = ERR_CONN;

                                             ^

      ../src/../SimpleMQ/src/seLwIP.c:67:39: note: each undeclared identifier is reported only once for each function it appears in

      ../src/../SimpleMQ/src/seLwIP.c:71:14: error: 'ERR_OK' undeclared (first use in this function)

          if(err != ERR_OK)

                    ^

      ../src/../SimpleMQ/src/seLwIP.c:73:21: error: 'ERR_TIMEOUT' undeclared (first use in this function)

             return err == ERR_TIMEOUT ? 0 : -1;

                           ^

      ../src/../SimpleMQ/src/seLwIP.c: In function 'se_bind':

      ../src/../SimpleMQ/src/seLwIP.c:83:4: warning: implicit declaration of function 'netconn_new' [-Wimplicit-function-declaration]

          sock->con = netconn_new(NETCONN_TCP);

          ^

      ../src/../SimpleMQ/src/seLwIP.c:83:28: error: 'NETCONN_TCP' undeclared (first use in this function)

          sock->con = netconn_new(NETCONN_TCP);

                                  ^

      ../src/../SimpleMQ/src/seLwIP.c:86:4: warning: implicit declaration of function 'netconn_bind' [-Wimplicit-function-declaration]

          if(netconn_bind(sock->con, IP_ADDR_ANY, port) == ERR_OK)

          ^

      ../src/../SimpleMQ/src/seLwIP.c:86:31: error: 'IP_ADDR_ANY' undeclared (first use in this function)

          if(netconn_bind(sock->con, IP_ADDR_ANY, port) == ERR_OK)

                                     ^

      ../src/../SimpleMQ/src/seLwIP.c:86:53: error: 'ERR_OK' undeclared (first use in this function)

          if(netconn_bind(sock->con, IP_ADDR_ANY, port) == ERR_OK)

                                                           ^

      ../src/../SimpleMQ/src/seLwIP.c:88:7: warning: implicit declaration of function 'netconn_listen' [-Wimplicit-function-declaration]

             if(netconn_listen(sock->con) == ERR_OK)

             ^

      ../src/../SimpleMQ/src/seLwIP.c:94:4: warning: implicit declaration of function 'netconn_delete' [-Wimplicit-function-declaration]

          netconn_delete(sock->con);

          ^

      ../src/../SimpleMQ/src/seLwIP.c: In function 'se_connect':

      ../src/../SimpleMQ/src/seLwIP.c:110:19: error: storage size of 'addr' isn't known

          struct ip_addr addr;

                         ^

      ../src/../SimpleMQ/src/seLwIP.c:115:4: warning: implicit declaration of function 'netconn_gethostbyname' [-Wimplicit-function-declaration]

          if(netconn_gethostbyname(name, &addr) != ERR_OK)

          ^

      ../src/../SimpleMQ/src/seLwIP.c:115:45: error: 'ERR_OK' undeclared (first use in this function)

          if(netconn_gethostbyname(name, &addr) != ERR_OK)

                                                   ^

      ../src/../SimpleMQ/src/seLwIP.c:117:28: error: 'NETCONN_TCP' undeclared (first use in this function)

          sock->con = netconn_new(NETCONN_TCP);

                                  ^

      ../src/../SimpleMQ/src/seLwIP.c:120:4: warning: implicit declaration of function 'netconn_connect' [-Wimplicit-function-declaration]

          if(netconn_connect(sock->con, &addr, port) == ERR_OK)

          ^

      ../src/../SimpleMQ/src/seLwIP.c:110:19: warning: unused variable 'addr' [-Wunused-variable]

          struct ip_addr addr;

                         ^

      ../src/../SimpleMQ/src/seLwIP.c: In function 'se_close':

      ../src/../SimpleMQ/src/seLwIP.c:134:7: warning: implicit declaration of function 'netbuf_delete' [-Wimplicit-function-declaration]

             netbuf_delete(sock->nbuf);

             ^

      ../src/../SimpleMQ/src/seLwIP.c: In function 'se_send':

      ../src/../SimpleMQ/src/seLwIP.c:142:4: error: unknown type name 'err_t'

          err_t err=netconn_write(sock->con, buf, len, NETCONN_COPY);

          ^

      ../src/../SimpleMQ/src/seLwIP.c:142:4: warning: implicit declaration of function 'netconn_write' [-Wimplicit-function-declaration]

      ../src/../SimpleMQ/src/seLwIP.c:142:49: error: 'NETCONN_COPY' undeclared (first use in this function)

          err_t err=netconn_write(sock->con, buf, len, NETCONN_COPY);

                                                       ^

      ../src/../SimpleMQ/src/seLwIP.c:143:14: error: 'ERR_OK' undeclared (first use in this function)

          if(err != ERR_OK)

                    ^

      ../src/../SimpleMQ/src/seLwIP.c: In function 'se_recv':

      ../src/../SimpleMQ/src/seLwIP.c:52:11: error: dereferencing pointer to incomplete type

          ((conn)->recv_timeout = (timeout))

                 ^

      ../src/../SimpleMQ/src/seLwIP.c:156:4: note: in expansion of macro 'netconn_set_recvtimeout'

          netconn_set_recvtimeout(sock->con, timeout == INFINITE_TMO ? 0 : timeout);

          ^

      ../src/../SimpleMQ/src/seLwIP.c:159:7: error: unknown type name 'err_t'

             err_t err;

             ^

      ../src/../SimpleMQ/src/seLwIP.c:162:7: warning: implicit declaration of function 'netconn_recv' [-Wimplicit-function-declaration]

             sock->nbuf = netconn_recv(sock->con);

             ^

      ../src/../SimpleMQ/src/seLwIP.c:162:18: warning: assignment makes pointer from integer without a cast [enabled by default]

             sock->nbuf = netconn_recv(sock->con);

                        ^

      ../src/../SimpleMQ/src/seLwIP.c:163:22: error: dereferencing pointer to incomplete type

             err = sock->con->err;

                            ^

      ../src/../SimpleMQ/src/seLwIP.c:164:37: error: 'ERR_CONN' undeclared (first use in this function)

             if(!sock->nbuf && !err) err = ERR_CONN;

        • 1. Re: Compile errors when using lwIP netconn API
          drp-WindRiver

          Hello:

           

          If you look in lwip/httpserver_raw/httpd.c you will see that err_t is used extensively in the raw http server example.  I think that this error chain was exasperated by the lwipopts you defined.

           

          This particular example shows a single threaded raw tcp implementation of a simple http server without sys_arch support. i.e. NO_SYS is defined in lwipopts.h

           

          If you had defined LWIP_NETCONN  as 1 (in lwipopts.h) and tried to recompile the raw http server example you would have gotten this error:

           

          ../src/../lwip/src/core/init.c:159:4: error: #error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h"

             #error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h"

           

          However, if you define NO_SYS as 0 then you have to provide sys_arch support which is not part of this example.  I think that an example of a netconn http server was developed after this example was published;  this supported the netconn and socket APis with the addition of sys_arch.  I will ask about plans to release an example with lwip and sys_arch support.

           

          thanks