在 Windows 中使用 open62541 构建一个简单的服务器

如何解决在 Windows 中使用 open62541 构建一个简单的服务器

我正在尝试通过参考此 page 中提供的文档使用 open62541 构建服务器。

我可以通过参考这个 webpage 生成 open62541.c 和 open62541.h 文件。 我按照描述使用 CMake 和 VisualStudio 生成了这些文件。当我尝试编译 myServer.c 文件时,出现以下错误。

大多数thr错误都描述了某个变量没有定义。我发现在open62541.h或open62541.c文件中没有定义UA_SOCKET,但在文档中写到这两个文件足以构建服务器文件.

有人成功编译服务器文件吗?谢谢。

错误

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,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,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,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,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,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,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,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,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,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,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,socklen_t *addrlen); | ^~~~~~~~~ open62541.h:30225:100: error: unknown type name 'socklen_t' 30225 | ssize_t UA_recvfrom(UA_SOCKET sockfd,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,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,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,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,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,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,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,| ^~ 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,socklen_t *addrlen);//equivalent to posix getsockname implementation

解决方法

请向他们投诉他们的构建说明。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)> insert overwrite table dwd_trade_cart_add_inc > select data.id, > data.user_id, > data.course_id, > date_format(
错误1 hive (edu)> insert into huanhuan values(1,'haoge'); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive> show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 <configuration> <property> <name>yarn.nodemanager.res