0

Currently, I am trying to build the PubSub example of the open62541 implementation. I have already gone through the documentation on how to build the examples a several times but I cannot figure it out.

I have tried to compile the PubSub tutorial examples. This includes the tutorial_pubsub_publish.c and the tutorial_pubsub_subscribe.c files. After I cloned the repository, I built the library as followed:

mkdir build 
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON - 
DUA_ENABLE_AMALGAMATION=ON -DUA_ENABLE_PUBSUB=ON ..
make

First I compiled the publish example which worked:

gcc -std=c99 -o PubSub_Publish_Example open62541.c tutorial_pubsub_publish.c

Then, I tried to compile the subscribe example in the same way like this:

gcc -std=c99 -o PubSub_Publish_Example open62541.c tutorial_pubsub_subscribe.c

This generated lots of errors - all saying "No such file or directory(first error was for the #include "ua_architecture_base.h") Then I tried to compile it with the ua_architecture_base.h and get other missing file or directory error and so on...

I also tried to compile the whole include folder of the open62541, but I also get "No such file or directory" errors:

gcc -std=c99 -I /home/theresa/Desktop/open62541/include -o PubSub_Subscribe_Example open62541.c tutorial_pubsub_subscribe.c

I also noticed that of all examples provided by the open62541 master, the tutorial_pubsub_subscribe.c file is the only example which does NOT include the open62541.h folder. Instead it includes a few other header files:

#include "ua_pubsub_networkmessage.h"
#include "ua_log_stdout.h"
#include "ua_server.h"
#include "ua_config_default.h"
#include "ua_pubsub.h"
#include "ua_network_pubsub_udp.h"
#ifdef UA_ENABLE_PUBSUB_ETH_UADP
     #include "ua_network_pubsub_ethernet.h"
#endif
#include "src_generated/ua_types_generated.h"
#include <stdio.h>
#include <signal.h>

So how can I compile and run the tutorial_pubsub_subscribe.c example and why does the subscriber example not include the open62541 header file?

user7335295
  • 401
  • 2
  • 7
  • 31

1 Answers1

1

I had success following the instructions "Building with CMake for Windows".
Using cmake-gui I selected the (advanced) features: UA_BUILD_EXAMPLES, UA_ENABLE_PUBSUB, UA_ENABLE_PUBSUB_INFORMATIONMODEL, UA_ENABLE_PUBSUB_INFORMATIONMODEL_METHODS, and UA_NAMESPACE_ZERO = FULL

Andrew Cullen
  • 838
  • 8
  • 14
  • hey @Andrew Cullen , where is the subscribe sample exe built? I successfully generated the cmake with your advanced build options, but I cannot find the executable anywhere? Moreover, I did not disable the build options which where enabled by default (like UA_ENABLE_SUBSCRIPTIONS, UA_ENABLE_SUBSCRIPTION_EVENTS, UA_ENABLE_NODESET_COMPILER_DESCRIPTIONS, ...). I hope this is ok? – user7335295 Mar 08 '19 at 08:23
  • Following "Building with CMake for Windows", I used cmake-gui and generated a \build folder. In this folder, I opened open62541.sln. Inside the solution is an \open62541\examples folder with dozens of visual studio projects. I opened the "tutorial_pubsub_publish.vcxproj" project and built it. The exe's are placed in \build\bin\examples\ – Andrew Cullen Mar 10 '19 at 01:15