CMake link to a C++ third party library (open62541)

342 views Asked by At

After multiple hours of researching the internet for an solution (I know there are somewhat similar questions but none were helping) I am close to throwing in the towel, so help is highly appreciated.

Preliminary: I want to use the C99 library open62541 for my own C++ project. I used the adequate build options for PubSub, since this is what I'm mostly interested in. I also configured the install path to /home/user/install/open62541.

Problem description: At first I was able to build everything as expected with this CMakeLists.txt. But at the moment I try to add the subscription capabilities of open62541 into the project but CMake is refusing to link the library into the project as it is supposed to:

  • I copied this example code from the tutorials to the project and added add_executable(subscriber ${CMAKE_CURRENT_SOURCE_DIR}/tutorial_pubsub_subscribe.cpp) and target_link_libraries(subscriber PUBLIC open62541) to my CMakeLists.txt.
  • CMake complains about the following: undefined reference to 'UA_PubSubConnection_regist'
  • I then went to the lib folder of my install path to find the libopen62541.so and
  • inspected the shared object with the nm command nm libopen62541.so | grep UA_PubSubConnection_regist
  • nm returned "t",

so i suppose the build of open62541 cannot be the reason for the linking error.

0

There are 0 answers