Error "undefined reference to "when import sdk lib in Qt

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

Moderator: uasdkcpp

Post Reply
Kangskii
Full Member
Full Member
Posts: 9
Joined: 21 Sep 2016, 04:15

Error "undefined reference to "when import sdk lib in Qt

Post by Kangskii »

Dear Support Team,
I success to build sdk via buildSdk.sh, but I fail to build Example by buildExample and cmake. The error is following:
[100%] Linking CXX executable client_cpp_sdk
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_globallookup: error: undefined reference to 'dlopen'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_globallookup: error: undefined reference to 'dlsym'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_globallookup: error: undefined reference to 'dlclose'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_bind_func: error: undefined reference to 'dlsym'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_bind_func: error: undefined reference to 'dlerror'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_bind_var: error: undefined reference to 'dlsym'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_bind_var: error: undefined reference to 'dlerror'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_load: error: undefined reference to 'dlopen'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_load: error: undefined reference to 'dlclose'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_load: error: undefined reference to 'dlerror'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_pathbyaddr: error: undefined reference to 'dladdr'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_pathbyaddr: error: undefined reference to 'dlerror'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o):dso_dlfcn.c:function dlfcn_unload: error: undefined reference to 'dlclose'
collect2: error: ld returned 1 exit status
client_cpp_sdk/CMakeFiles/client_cpp_sdk.dir/build.make:227: recipe for target 'client_cpp_sdk/client_cpp_sdk' failed
make[2]: *** [client_cpp_sdk/client_cpp_sdk] Error 1
CMakeFiles/Makefile2:1020: recipe for target 'client_cpp_sdk/CMakeFiles/client_cpp_sdk.dir/all' failed
make[1]: *** [client_cpp_sdk/CMakeFiles/client_cpp_sdk.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Because I suceess to build sdk, I try to build the code the directory in client_gettingstart lesson02(via copy not add existing file), the Qt will show error "undefined reference to "UaUserIdentityTokenUserPassword::UaUserIdentityTokenUserPassword()", and this kind of the error is above 900.
I think the reson is linking about build Examples. Support Team, can you give me some advice ?
The platform is Debian, the sdk vesion is V1.5.5-355, Qt Creator version is 4.2.0, and the cmake version is 3.7.2 .

Kangskii
Full Member
Full Member
Posts: 9
Joined: 21 Sep 2016, 04:15

Re: Error "undefined reference to "when import sdk lib in Qt

Post by Kangskii »

Dear,
sorry to forget to say about version of the third party, the openssl is 1.0.0-d, and the libxml2 is 2.7.7, and the platform is Debian in raspberry.
Thanks !

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Error "undefined reference to "when import sdk lib in Qt

Post by Support Team »

Hello Kangskii,

it seems that you are using third-party files (e.g.: OpenSSL or LibXml2) which you have built by your own. This is no problem in general, but you have to link against additional libraries. These libs are not used in pre-built third-party libs because of patented algorithms. The only thing you have to do is to write these "additional" libs into the CMakeLists.txt file of all applications you want to build. See this example for the CMakeLists.txt of sdk/examples/server_cpp_demo (added dl library):

Code: Select all

target_link_libraries(${PROJECT_NAME}
                      ${UAMODULE_LIBRARY}
                      ${UACOREMODULE_LIBRARY}
                      ${UAPKI_LIBRARY}
                      ${UABASE_LIBRARY}
                      ${UASTACK_LIBRARY}
                      ${SYSTEM_LIBS}
                      dl)
Best regards
Unified Automation Support Team

Post Reply