![]() Registered Member ![]()
|
Hello,
I want to include some KDE classes in a library. So I put the find_package(KDE4 REQUIRED) statement into the CMakeLists.txt of the library. The compilation and installation of it (as shared object) works without errors. But when I link an application against the library I get "undefined reference to" errors. The errors disappear when I remove the find_package(KDE4 REQUIRED) statement from the CMakeLists.txt of the library. Is there anything I if have to consider when I want to use KDE classes in a library? I attached some files which demonstrate the problem on a minimalistic application: The error message I get when I try to link against the library is
Folder structure app |-build |-src |--main.cpp |--CMakeLists.txt lib |-build |-src |--CMakeLists.txt |--libclass.cpp |--libclass.h app CMakeLists.txt
app main.cpp
lib CMakeLists.txt
lib libclass.cpp
lib libclass.h
|
![]() KDE Developer ![]()
|
The undefined reference error is reporting it can't find your class's method.
My guess would be that this is because there is no EXPORT macro. Add this header:
and in your libclass.h you add this between "class" and the class name
Cheers, _
anda_skoa, proud to be a member of KDE forums since 2008-Oct.
|
![]() Registered Member ![]()
|
Thanks a lot. That solved the problem.
|
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]