ua_pubsub.h: No such file or directory

img


img

按照截图中激活选项UA_ENABLE_PUBSUB等,详见截图,并修改cmakeLists文件option(UA_ENABLE_PUBSUB_MQTT "Enable publish/subscribe with mqtt (experimental)" ON),off置位on;然后//cmake .. //make //sudo make install;成功后编译example中tutorial_pubsub_mqtt_publish.c文件,结果见运行结果及报错内容。
include
include
include "ua_pubsub.h"
include

tutorial_pubsub_mqtt_publish.c: In function ‘main’:
tutorial_pubsub_mqtt_publish.c:463:53: warning: implicit declaration of function ‘UA_PubSubTransportLayerMQTT’; did you mean ‘UA_PubSubTransportLayerUDPMP’? [-Wimplicit-function-declaration]
  463 |     UA_ServerConfig_addPubSubTransportLayer(config, UA_PubSubTransportLayerMQTT());
      |                                                     ^
      |                                                     UA_PubSubTransportLayerUDPMP
tutorial_pubsub_mqtt_publish.c:463:53: error: incompatible type for argument 2 of ‘UA_ServerConfig_addPubSubTransportLayer’
  463 |     UA_ServerConfig_addPubSubTransportLayer(config, UA_PubSubTransportLayerMQTT());
      |                                                     ^
      |                                                     |
      |                                                     int
In file included from tutorial_pubsub_mqtt_publish.c:50:
open62541.h:37463:65: note: expected ‘UA_PubSubTransportLayer’ {aka ‘struct ’} but argument is of typeint37463 |                                         UA_PubSubTransportLayer pubsubTransportLayer);
      |                                        
tutorial_pubsub_mqtt_publish.c:475:5: error: unknown type name ‘UA_PubSubConnection’; did you mean ‘UA_PubSubConfiguration’?
  475 |     UA_PubSubConnection *connection = UA_PubSubConnection_findConnectionbyId(server, connectionIdent);
      |     ^
      |     UA_PubSubConfiguration
tutorial_pubsub_mqtt_publish.c:475:39: warning: implicit declaration of function ‘UA_PubSubConnection_findConnectionbyId’ [-Wimplicit-function-declaration]
  475 |     UA_PubSubConnection *connection = UA_PubSubConnection_findConnectionbyId(server, connectionIdent);
      |                                       ^
tutorial_pubsub_mqtt_publish.c:475:39: warning: initialization ofint *’ fromint’ makes pointer from integer without a cast [-Wint-conversion]

gcc -std=c99 tutorial_pubsub_mqtt_publish.c -o myServer
tutorial_pubsub_mqtt_publish.c:47:10: fatal error: ua_pubsub.h: No such file or directory
47 | #include "ua_pubsub.h"
| ^
compilation terminated.

激活cmake选项UA_ENABLE_amalgamation,删除原build文件夹,重新编译;编译成功后将tutorial_pubsub_mqtt_publish.c文件中头文件引用改为“open62541.h",详细如下:
include "open62541.h"

include

编译gcc -std=c99 open62541.c tutorial_pubsub_mqtt_publish.c -o myServer
出现如下报错:
见代码@爱就是恒久忍耐

编译通过,生成可执行文件。

勾选上UA_BUILD_EXAMPLES

img

ua_pubsub.h头文件到底在哪?