Undefined reference to 'UaPkiCertificate'. Using CMake.

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
craigh
Jr. Member
Jr. Member
Posts: 1
Joined: 25 Jul 2019, 14:30

Undefined reference to 'UaPkiCertificate'. Using CMake.

Post by craigh »

I cannot build a simple client using linux and cmake. I am using the pre-built uasdkcpp libraries found here: https://www.unified-automation.com/down ... pment.html , and I have installed the required libssl-dev and Libxml2.
When I try to build I get the error:

Code: Select all

/home/buildbot/work/uasdkcpp/src/uaclient/uaclientcpp/uaclientsdk.cpp:908: error: undefined reference to `UaPkiCertificate::UaPkiCertificate()'
My CMake:

Code: Select all

project(COPCUA_TEST)
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/externals/uasdkcpp/cmake)

set(testprefix ${CMAKE_SOURCE_DIR}/test/tests)

set(${PROJECT_NAME}_test_srcs
	${testprefix}/ua_lib_link_test.cpp
	${testprefix}/cortex_lib_link_test.cpp
	${testprefix}/weather_server_client_test.cpp
)

#Link with uasdkcpp
find_package(UASDK REQUIRED)
find_package(UaOpenSSL REQUIRED)
find_package(UaLibXml2 REQUIRED)
include(ConfigureUaStack)
include(ConfigureCppSdk)

if (UNIX) # Set up the RPATH (note: not the RUNPATH, for compatibility with DDS)
	set(CMAKE_BUILD_WITH_INSTALL_RPATH  TRUE)
	set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
	set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN")
	set(CMAKE_EXE_LINKER_FLAGS "-Wl,--disable-new-dtags")
endif()

message(" UA LIBS:
	${UAPKI_LIBRARY}
	${UACLIENT_LIBRARY}
	${UABASE_LIBRARY}
	${UASTACK_LIBRARY}")


include(externals/UnitTests/CMakeScripts/MakeTests.cmake)
MakeTests(
	PREFIX Copcua_
	TESTS ${${PROJECT_NAME}_test_srcs}
	DEPENDENCIES
		COPCUA_COMMON
		${UAPKI_LIBRARY}
		${OPENSSL_LIBRARIES}
		${UACLIENT_LIBRARY}
		${UABASE_LIBRARY}
		${UASTACK_LIBRARY}
	LINKDIR
		${UA_LIB_DIR}
)

# Copy OPC-UA runtime libraries to build directory
file(COPY
	${UA_LIB_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}uastack${CMAKE_SHARED_LIBRARY_SUFFIX}
	DESTINATION ${CMAKE_BINARY_DIR}/lib
)
Where the MakeTests scripts simply does the following for each .cpp file:

Code: Select all

			
			# create executable
			add_executable("${target_name}" "${test_file}" "${MakeTests_SOURCE}")
			set_target_properties("${target_name}" PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
			set_target_properties("${target_name}" PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)

			# link dependant libraries
			target_include_directories(${target_name} PRIVATE ${MakeTests_INCLUDES})
			target_link_libraries(${target_name} gtest_main)
			target_link_libraries(${target_name} ${MakeTests_DEPENDENCIES})
			message("Linking test ${target_name} with: gtest_main ${MakeTests_DEPENDENCIES}")
			target_link_directories(${target_name} PRIVATE ${MakeTests_LINKDIR})
			message("Linking test ${target_name} with: directory ${MakeTests_LINKDIR}")
The verbose output:

Code: Select all

[ 99%] Linking CXX executable ../bin/Copcua_weather_server_client_test
cd /home/craig/Git/cortex-opc-ua/build/Debug/test && /home/craig/.local/lib/python2.7/site-packages/cmake/data/bin/cmake -E cmake_link_script CMakeFiles/Copcua_weather_server_client_test.dir/link.txt --verbose=1

/usr/bin/x86_64-linux-gnu-g++-6  -g  -Wl,--disable-new-dtags -rdynamic CMakeFiles/Copcua_weather_server_client_test.dir/tests/weather_server_client_test.cpp.o  -o ../bin/Copcua_weather_server_client_test  -L/home/craig/Git/cortex-opc-ua/externals/uasdkcpp/cmake/../lib -Wl,-rpath,"\$ORIGIN/../lib:\$ORIGIN" googletest/googlemock/gtest/libgtest_maind.so ../common/libCOPCUA_COMMONd.a -luapkicppd -lssl -lcrypto -luaclientcppd -luabasecppd -luastackd googletest/googlemock/gtest/libgtestd.so -pthread ../lib/libCortexCored.so ../lib/archive/libLogging_STATICd.a ../lib/archive/libCommon_STATICd.a -lrt

/home/craig/Git/cortex-opc-ua/externals/uasdkcpp/cmake/../lib/libuaclientcppd.a(uaclientsdk.cpp.o): In function `UaClientSdk::SessionSecurityInfo::saveServerCertificate(UaString&)':
/home/buildbot/work/uasdkcpp/src/uaclient/uaclientcpp/uaclientsdk.cpp:908: undefined reference to `UaPkiCertificate::UaPkiCertificate()'
/home/buildbot/work/uasdkcpp/src/uaclient/uaclientcpp/uaclientsdk.cpp:910: undefined reference to `UaPkiCertificate::fromDER(UaByteArray const&)'
/home/buildbot/work/uasdkcpp/src/uaclient/uaclientcpp/uaclientsdk.cpp:910: undefined reference to `UaPkiCertificate::operator=(UaPkiCertificate const&)'
/home/buildbot/work/uasdkcpp/src/uaclient/uaclientcpp/uaclientsdk.cpp:910: undefined reference to `UaPkiCertificate::~UaPkiCertificate()'
...]
Can somebody please let me know where I am going wrong?

Thanks.

Post Reply