Building a simple server using open62541 in Windows

655 views Asked by At

I am trying to build a server using open62541 by referring to the documentation provided at this page.

I am able to generate the open62541.c and open62541.h files by referring to this webpage. I generated these files using CMake and VisualStudio as described. When I try to compile the myServer.c file, I am getting the following errors.

Most of thr errors describe that certain variable is not defined.I found that UA_SOCKET is not defined in open62541.h or open62541.c files,but in the documentation it is written that these two files are sufficient to build the server file.

Is anyone successful in compiling the server file?Thanks.

Error

In file included from open62541.c:28: open62541.h:22834:5: error: unknown type name 'UA_SOCKET' 22834 | UA_SOCKET sockfd; /* Most connectivity solutions run on | ^~~~~~~~~ open62541.h:30209:1: error: unknown type name 'ssize_t'; did you mean '_ssize_t'? 30209 | ssize_t UA_send(UA_SOCKET sockfd, const void *buf, size_t len, int flags); //equivalent to posix send implementation | ^~~~~~~ | _ssize_t open62541.h:30209:17: error: unknown type name 'UA_SOCKET' 30209 | ssize_t UA_send(UA_SOCKET sockfd, const void *buf, size_t len, int flags); //equivalent to posix send implementation | ^~~~~~~~~ open62541.h:30213:1: error: unknown type name 'ssize_t'; did you mean '_ssize_t'? 30213 | ssize_t UA_sendto(UA_SOCKET sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); //equivalent to posix sendto implementation | ^~~~~~~ | _ssize_t open62541.h:30213:19: error: unknown type name 'UA_SOCKET' 30213 | ssize_t UA_sendto(UA_SOCKET sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); //equivalent to posix sendto implementation | ^~~~~~~~~ open62541.h:30213:111: error: unknown type name 'socklen_t' 30213 | ssize_t UA_sendto(UA_SOCKET sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); //equivalent to posix sendto implementation | ^~~~~~~~~ open62541.h:30217:15: error: unknown type name 'UA_SOCKET' 30217 | int UA_select(UA_SOCKET nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); //equivalent to posix select implementation | ^~~~~~~~~ open62541.h:30217:31: error: unknown type name 'fd_set' 30217 | int UA_select(UA_SOCKET nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); //equivalent to posix select implementation | ^~~~~~ open62541.h:30217:48: error: unknown type name 'fd_set' 30217 | int UA_select(UA_SOCKET nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); //equivalent to posix select implementation | ^~~~~~ open62541.h:30217:66: error: unknown type name 'fd_set' 30217 | int UA_select(UA_SOCKET nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); //equivalent to posix select implementation | ^~~~~~ open62541.h:30221:1: error: unknown type name 'ssize_t'; did you mean '_ssize_t'? 30221 | ssize_t UA_recv(UA_SOCKET sockfd, void *buf, size_t len, int flags); //equivalent to posix recv implementation | ^~~~~~~ | _ssize_t open62541.h:30221:17: error: unknown type name 'UA_SOCKET' 30221 | ssize_t UA_recv(UA_SOCKET sockfd, void *buf, size_t len, int flags); //equivalent to posix recv implementation | ^~~~~~~~~ open62541.h:30225:1: error: unknown type name 'ssize_t'; did you mean '_ssize_t'? 30225 | ssize_t UA_recvfrom(UA_SOCKET sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); | ^~~~~~~ | _ssize_t open62541.h:30225:21: error: unknown type name 'UA_SOCKET' 30225 | ssize_t UA_recvfrom(UA_SOCKET sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); | ^~~~~~~~~ open62541.h:30225:100: error: unknown type name 'socklen_t' 30225 | ssize_t UA_recvfrom(UA_SOCKET sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); | ^~~~~~~~~ open62541.h:30229:17: error: unknown type name 'UA_SOCKET' 30229 | int UA_shutdown(UA_SOCKET sockfd, int how); //equivalent to posix shutdown implementation | ^~~~~~~~~ open62541.h:30233:1: error: unknown type name 'UA_SOCKET' 30233 | UA_SOCKET UA_socket(int domain, int type, int protocol);//equivalent to posix socket implementation | ^~~~~~~~~ open62541.h:30237:13: error: unknown type name 'UA_SOCKET' 30237 | int UA_bind(UA_SOCKET sockfd, const struct sockaddr *addr, socklen_t addrlen);//equivalent to posix bind implementation | ^~~~~~~~~ open62541.h:30237:60: error: unknown type name 'socklen_t' 30237 | int UA_bind(UA_SOCKET sockfd, const struct sockaddr *addr, socklen_t addrlen);//equivalent to posix bind implementation | ^~~~~~~~~ open62541.h:30241:15: error: unknown type name 'UA_SOCKET' 30241 | int UA_listen(UA_SOCKET sockfd, int backlog);//equivalent to posix listen implementation | ^~~~~~~~~ open62541.h:30245:15: error: unknown type name 'UA_SOCKET' 30245 | int UA_accept(UA_SOCKET sockfd, struct sockaddr *addr, socklen_t *addrlen);//equivalent to posix accept implementation | ^~~~~~~~~ open62541.h:30245:56: error: unknown type name 'socklen_t' 30245 | int UA_accept(UA_SOCKET sockfd, struct sockaddr *addr, socklen_t *addrlen);//equivalent to posix accept implementation | ^~~~~~~~~ open62541.h:30249:14: error: unknown type name 'UA_SOCKET' 30249 | int UA_close(UA_SOCKET sockfd);//equivalent to posix close implementation | ^~~~~~~~~ open62541.h:30253:16: error: unknown type name 'UA_SOCKET' 30253 | int UA_connect(UA_SOCKET sockfd, const struct sockaddr *addr, socklen_t addrlen);//equivalent to posix connect implementation | ^~~~~~~~~ open62541.h:30253:63: error: unknown type name 'socklen_t' 30253 | int UA_connect(UA_SOCKET sockfd, const struct sockaddr *addr, socklen_t addrlen);//equivalent to posix connect implementation | ^~~~~~~~~ open62541.h:30257:16: error: unknown type name 'UA_SOCKET' 30257 | void UA_fd_set(UA_SOCKET fd, fd_set *set); //equivalent to posix FD_SET implementation | ^~~~~~~~~ open62541.h:30257:30: error: unknown type name 'fd_set' 30257 | void UA_fd_set(UA_SOCKET fd, fd_set *set); //equivalent to posix FD_SET implementation | ^~~~~~ open62541.h:30261:17: error: unknown type name 'UA_SOCKET' 30261 | int UA_fd_isset(UA_SOCKET fd, fd_set *set);//equivalent to posix FD_ISSET implementation | ^~~~~~~~~ open62541.h:30261:31: error: unknown type name 'fd_set' 30261 | int UA_fd_isset(UA_SOCKET fd, fd_set *set);//equivalent to posix FD_ISSET implementation | ^~~~~~ open62541.h:30265:72: warning: 'struct addrinfo' declared inside parameter list will not be visible outside of this definition or declaration 30265 | int UA_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);//equivalent to posix getaddrinfo implementation | ^~~~~~~~ open62541.h:30287:37: error: unknown type name 'UA_SOCKET' 30287 | unsigned int UA_socket_set_blocking(UA_SOCKET sockfd);//set a socket as blocking. Returns 0 if OK, other value otherwise | ^~~~~~~~~ open62541.h:30291:40: error: unknown type name 'UA_SOCKET' 30291 | unsigned int UA_socket_set_nonblocking(UA_SOCKET sockfd);//set a socket as non-blocking. Returns 0 if OK, other value otherwise | ^~~~~~~~~ open62541.h:30295:69: error: unknown type name 'socklen_t' 30295 | int UA_getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen); //equivalent to posix getsockopt implementation. Only in non windows architectures | ^~~~~~~~~ open62541.h:30299:75: error: unknown type name 'socklen_t' 30299 | int UA_setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen);//equivalent to posix setsockopt implementation | ^~~~~~~~~ open62541.h:30303:29: warning: 'struct addrinfo' declared inside parameter list will not be visible outside of this definition or declaration 30303 | void UA_freeaddrinfo(struct addrinfo *res);//equivalent to posix freeaddrinfo implementatio | ^~~~~~~~ open62541.h:30311:55: error: unknown type name 'socklen_t' 30311 | int UA_getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen);//equivalent to posix getsockname implementation | ^~~~~~~~~ open62541.c: In function 'UA_Timer_init': open62541.c:19600:5: warning: implicit declaration of function 'UA_LOCK_INIT'; did you mean 'UA_LOG_INFO'? [-Wimplicit-function-declaration] 19600 | UA_LOCK_INIT(&t->timerMutex); | ^~~~~~~~~~~~ | UA_LOG_INFO open62541.c:19600:20: error: 'UA_Timer' has no member named 'timerMutex' 19600 | UA_LOCK_INIT(&t->timerMutex); | ^~ open62541.c: In function 'UA_Timer_addTimerEntry': open62541.c:19605:5: warning: implicit declaration of function 'UA_LOCK' [-Wimplicit-function-declaration] 19605 | UA_LOCK(&t->timerMutex); | ^~~~~~~ open62541.c:19605:15: error: 'UA_Timer' has no member named 'timerMutex' 19605 | UA_LOCK(&t->timerMutex); | ^~ open62541.c:19611:5: warning: implicit declaration of function 'UA_UNLOCK' [-Wimplicit-function-declaration] 19611 | UA_UNLOCK(&t->timerMutex); | ^~~~~~~~~ open62541.c:19611:17: error: 'UA_Timer' has no member named 'timerMutex' 19611 | UA_UNLOCK(&t->timerMutex); | ^~ 37908 | UA_LOCK(&server->serviceMutex); | ^~ open62541.c:37910:22: error: 'UA_Server' has no member named 'serviceMutex' 37910 | UA_UNLOCK(&server->serviceMutex); | ^~ open62541.c: In function 'Service_FindServers': open62541.c:38031:27: error: 'UA_Server' has no member named 'serviceMutex' 38031 | UA_LOCK_ASSERT(&server->serviceMutex, 1); | ^~ open62541.c: In function 'Service_GetEndpoints': open62541.c:38115:27: error: 'UA_Server' has no member named 'serviceMutex' 38115 | UA_LOCK_ASSERT(&server->serviceMutex, 1); | ^~ open62541.c: In function 'setSubscriptionSettings': open62541.c:38662:27: error: 'UA_Server' has no member named 'serviceMutex' 38662 | UA_LOCK_ASSERT(&server->serviceMutex, 1)ent 2 of 'addServerSocket' from incompatible pointer type [-Wincompatible-pointer-types] 64148 | UA_StatusCode statusCode = addServerSocket(layer, ai); | ^~ | | | struct addrinfo * open62541.c:64006:64: note: expected 'struct addrinfo *' but argument is of type 'struct addrinfo *' 64006 | addServerSocket(ServerNetworkLayerTCP *layer, struct addrinfo *ai) { | ~~~~~~~~~~~~~~~~~^~ open62541.c:64151:29: warning: passing argument 1 of 'UA_freeaddrinfo' from incompatible pointer type [-Wincompatible-pointer-types] 64151 | UA_freeaddrinfo(res); | ^~~ | | | struct addrinfo * In file included from open62541.c:28: open62541.h:30303:39: note: expected 'struct addrinfo *' but argument is of type 'struct addrinfo *' 30303 | void UA_freeaddrinfo(struct addrinfo *res);//equivalent to posix freeaddrinfo implementatio | ~~~~~~~~~~~~~~~~~^~~ open62541.c:64155:21: warning: passing argument 1 of 'UA_freeaddrinfo' from incompatible pointer type [-Wincompatible-pointer-types] 64155 | UA_freeaddrinfo(res); | ^~~ | | | struct addrinfo * In file included from open62541.c:28: open62541.h:30303:39: note: expected 'struct addrinfo *' but argument is of type 'struct addrinfo *' 30303 | void UA_freeaddrinfo(struct addrinfo *res);//equivalent to posix freeaddrinfo implementatio | ~~~~~~~~~~~~~~~~~^~~ open62541.c: At top level: open62541.c:64186:40: error: unknown type name 'fd_set' 64186 | setFDSet(ServerNetworkLayerTCP *layer, fd_set *fdset) { | ^~~~~~ open62541.c: In function 'ServerNetworkLayerTCP_listen': open62541.c:64215:5: error: unknown type name 'fd_set' 64215 | fd_set fdset, errset; | ^~~~~~ open62541.c:64216:26: warning: implicit declaration of function 'setFDSet' [-Wimplicit-function-declaration] 64216 | UA_Int32 highestfd = setFDSet(layer, &fdset); | ^~~~~~~~ open62541.c:64218:12: error: variable 'tmptv' has initializer but incomplete type 64218 | struct timeval tmptv = {0, timeout * 1000}; | ^~~~~~~ open62541.c:64218:29: warning: excess elements in struct initializer 64218 | struct timeval tmptv = {0, timeout * 1000}; | ^ open62541.c:64218:29: note: (near initialization for 'tmptv') open62541.c:64218:32: warning: excess elements in struct initializer 64218 | struct timeval tmptv = {0, timeout * 1000}; | ^~~~~~~ open62541.c:64218:32: note: (near initialization for 'tmptv') open62541.c:64218:20: error: storage size of 'tmptv' isn't known 64218 | struct timeval tmptv = {0, timeout * 1000}; | ^~~~~ open62541.c:64222:60: error: 'errno_str' undeclared (first use in this function) 64222 | "Socket select failed with %s", errno_str)); | ^~~~~~~~~ open62541.c:64229:13: warning: implicit declaration of function 'UA_fd_isset' [-Wimplicit-function-declaration] 64229 | if(!UA_fd_isset(layer->serverSockets[i], &fdset)) | ^~~~~~~~~~~ open62541.c:64232:33: error: storage size of 'remote' isn't known 64232 | struct sockaddr_storage remote; | ^~~~~~ open62541.c:64233:9: error: unknown type name 'socklen_t' 64233 | socklen_t remote_size = sizeof(remote); | ^~~~~~~~~ open62541.c:64234:9: error: unknown type name 'UA_SOCKET' 64234 | UA_SOCKET newsockfd = UA_accept(layer->serverSockets[i], | ^~~~~~~~~ open62541.c:64234:31: warning: implicit declaration of function 'UA_accept'; did you mean 'UA_access'? [-Wimplicit-function-declaration] 64234 | UA_SOCKET newsockfd = UA_accept(layer->serverSockets[i], | ^~~~~~~~~ | UA_access open62541.c:64236:25: error: 'UA_INVALID_SOCKET' undeclared (first use in this function) 64236 | if(newsockfd == UA_INVALID_SOCKET) | ^~~~~~~~~~~~~~~~~ open62541.c: At top level: open62541.c:64373:21: error: field 'hints' has incomplete type 64373 | struct addrinfo hints, *server; | ^~~~~ open62541.c: In function 'ClientNetworkLayerTCP_close': open62541.c:64388:30: error: 'UA_INVALID_SOCKET' undeclared (first use in this function) 64388 | if(connection->sockfd != UA_INVALID_SOCKET) { | ^~~~~~~~~~~~~~~~~ open62541.c: In function 'ClientNetworkLayerTCP_free': open62541.c:64402:38: warning: passing argument 1 of 'UA_freeaddrinfo' from incompatible pointer type [-Wincompatible-pointer-types] 64402 | UA_freeaddrinfo(tcpConnection->server); | ~~~~~~~~~~~~~^~~~~~~~ | | | struct addrinfo * In file included from open62541.c:28: open62541.h:30303:39: note: expected 'struct addrinfo *' but argument is of type 'struct addrinfo *' 30303 | void UA_freeaddrinfo(struct addrinfo *res);//equivalent to posix freeaddrinfo implementatio | ~~~~~~~~~~~~~~~~~^~~ open62541.c: In function 'UA_ClientConnectionTCP_poll': open62541.c:64426:30: error: 'UA_INVALID_SOCKET' undeclared (first use in this function) 64426 | if(connection->sockfd == UA_INVALID_SOCKET) { | ^~~~~~~~~~~~~~~~~ open62541.c:64427:61: error: invalid use of undefined type 'struct addrinfo' 64427 | connection->sockfd = UA_socket(tcpConnection->server->ai_family, | ^~ open62541.c:64428:61: error: invalid use of undefined type 'struct addrinfo' 64428 | tcpConnection->server->ai_socktype, | ^~ open62541.c:64429:61: error: invalid use of undefined type 'struct addrinfo' 64429 | tcpConnection->server->ai_protocol); | ^~ open62541.c:64432:68: error: 'UA_ERRNO' undeclared (first use in this function) 64432 | "Could not create client socket: %s", strerror(UA_ERRNO)); | ^~~~~~~~ open62541.c:64457:17: warning: implicit declaration of function 'UA_connect' [-Wimplicit-function-declaration] 64457 | int error = UA_connect(connection->sockfd, tcpConnection->server->ai_addr, | ^~~~~~~~~~ open62541.c:64457:69: error: invalid use of undefined type 'struct addrinfo' 64457 | int error = UA_connect(connection->sockfd, tcpConnection->server->ai_addr, | ^~ open62541.c:64458:49: error: invalid use of undefined type 'struct addrinfo' 64458 | tcpConnection->server->ai_addrlen); | ^~ open62541.c:64467:20: error: 'UA_ERR_CONNECTION_PROGRESS' undeclared (first use in this function) 64467 | if(UA_ERRNO != UA_ERR_CONNECTION_PROGRESS) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~ open62541.c:64503:5: error: unknown type name 'fd_set' 64503 | fd_set fdset; | ^~~~~~ open62541.c:64506:12: error: variable 'tmptv' has initializer but incomplete type 64506 | struct timeval tmptv = { (long int) (timeout_usec / 1000000), | ^~~~~~~ open62541.c:64506:30: warning: excess elements in struct initializer 64506 | struct timeval tmptv = { (long int) (timeout_usec / 1000000), | ^ open62541.c:64506:30: note: (near initialization for 'tmptv') open62541.c:64507:30: warning: excess elements in struct initializer 64507 | (int) (timeout_usec % 1000000) }; | ^ ^~~~~~~~~ open62541.h:30253:16: error: unknown type name 'UA_SOCKET' 30253 | int UA_connect(UA_SOCKET sockfd, const struct sockaddr *addr, socklen_t addrlen);//equivalent to posix connect implementation | ^~~~~~~~~ open62541.h:30253:63: error: unknown type name 'socklen_t' 30253 | int UA_connect(UA_SOCKET sockfd, const struct sockaddr *addr, socklen_t addrlen);//equivalent to posix connect implementation | ^~~~~~~~~ open62541.h:30257:16: error: unknown type name 'UA_SOCKET' 30257 | void UA_fd_set(UA_SOCKET fd, fd_set *set); //equivalent to posix FD_SET implementation | ^~~~~~~~~ open62541.h:30257:30: error: unknown type name 'fd_set' 30257 | void UA_fd_set(UA_SOCKET fd, fd_set *set); //equivalent to posix FD_SET implementation | ^~~~~~ open62541.h:30261:17: error: unknown type name 'UA_SOCKET' 30261 | int UA_fd_isset(UA_SOCKET fd, fd_set *set);//equivalent to posix FD_ISSET implementation | ^~~~~~~~~ open62541.h:30261:31: error: unknown type name 'fd_set' 30261 | int UA_fd_isset(UA_SOCKET fd, fd_set *set);//equivalent to posix FD_ISSET implementation | ^~~~~~ open62541.h:30265:72: warning: 'struct addrinfo' declared inside parameter list will not be visible outside of this definition or declaration 30265 | int UA_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);//equivalent to posix getaddrinfo implementation | ^~~~~~~~ open62541.h:30287:37: error: unknown type name 'UA_SOCKET' 30287 | unsigned int UA_socket_set_blocking(UA_SOCKET sockfd);//set a socket as blocking. Returns 0 if OK, other value otherwise | ^~~~~~~~~ open62541.h:30291:40: error: unknown type name 'UA_SOCKET' 30291 | unsigned int UA_socket_set_nonblocking(UA_SOCKET sockfd);//set a socket as non-blocking. Returns 0 if OK, other value otherwise | ^~~~~~~~~ open62541.h:30295:69: error: unknown type name 'socklen_t' 30295 | int UA_getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen); //equivalent to posix getsockopt implementation. Only in non windows architectures | ^~~~~~~~~ open62541.h:30299:75: error: unknown type name 'socklen_t' 30299 | int UA_setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen);//equivalent to posix setsockopt implementation | ^~~~~~~~~ open62541.h:30303:29: warning: 'struct addrinfo' declared inside parameter list will not be visible outside of this definition or declaration 30303 | void UA_freeaddrinfo(struct addrinfo *res);//equivalent to posix freeaddrinfo implementatio | ^~~~~~~~ open62541.h:30311:55: error: unknown type name 'socklen_t' 30311 | int UA_getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen);//equivalent to posix getsockname implementation

1

There are 1 answers

0
Cheatah On

Please complain to them about their build instructions.