Undefined references when trying to add (auto)tests to EventViews
laurent Montel
montel at kde.org
Fri Jan 12 15:01:57 GMT 2018
Le vendredi 12 janvier 2018, 15:12:55 CET kdenis at posteo.de a écrit :
> Hi. I tried to write some tests for the eventviews library, but could not
> get past some undefined reference errors.
> Here is a minimized version of what I tried.
>
> I added a new directory "autotests" and the line
> "add_subdirectory(autotests)" in /CMakeLists.txt, right below
> "add_subdirectory(tests)".
> Then, I created the file "autotests/incidencetreemodel_test.cpp":
>
>
> #include <todo/incidencetreemodel.h>
> int main() {
> IncidenceTreeModel model;
> }
> <<<
>
> and the file "autotests/CMakeLists.txt":
>
>
> add_executable(incidencetreemodel_test incidencetreemodel_test.cpp)
> target_link_libraries(incidencetreemodel_test KF5EventViews)
> <<<
>
> It compiles just fine, but linking fails with:
>
>
> [ 90%] Linking CXX executable ../bin/incidencetreemodel_test
> CMakeFiles/incidencetreemodel_test.dir/incidencetreemodel_test.cpp.o: In
> function `main':
> /home/kde/test/eventviews/autotests/incidencetreemodel_test.cpp:28:
> undefined reference to `IncidenceTreeModel::IncidenceTreeModel(QObject*)'
> /home/kde/test/eventviews/autotests/incidencetreemodel_test.cpp:28:
> undefined reference to `IncidenceTreeModel::~IncidenceTreeModel()'
> collect2: error: ld returned 1 exit status
> make[2]: ***
> [autotests/CMakeFiles/incidencetreemodel_test.dir/build.make:121:
> bin/incidencetreemodel_test] Error 1
> make[1]: *** [CMakeFiles/Makefile2:329: autotests/CMakeFiles/
> incidencetreemodel_test.dir/all] Error 2
> make: *** [Makefile:141: all] Error 2
> <<<
>
> todo/incidencetreemodel.cpp is one of the source files added to
> KF5EventViews, and I linked my test binary to KF5EventViews.
> CMake seems to set include directories correctly, too, since <todo/
> incidencetreemodel.h> (and the class IncidenceTreeModel) is found.
>
> Can anyone please help me fix this problem?
Missing export symbol ?
--
Laurent Montel | laurent.montel at kdab.com | KDE/Qt Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53,
www.kdab.fr KDAB - The Qt, C++ and OpenGL Experts - Platform-independent
software solutions
More information about the kde-pim
mailing list