<div dir="ltr">I fixed your problem. Get the attached patch and apply it with "git apply <patch_file>".<div><br></div><div>The kImageAnnotator constructor was private to the library (I just learned that Qt does that when creating shared libraries), and that's why you get the undefined reference error. You could have checked it with:</div><div><br></div><div>nm lib/libkImageAnnotator.so | c++filt | grep ::KImage</div><div>00000000000141f6 t KImageAnnotator::KImageAnnotator(QPixmap const&)</div><div>00000000000141f6 t KImageAnnotator::KImageAnnotator(QPixmap const&)</div><div><br></div><div>The "t" shows it is private.</div><div><br></div><div>You have to set the proper export macros to make it visible:</div><div><br></div><div><a href="https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application">https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application</a><br></div><div><a href="http://doc.qt.io/qt-5/sharedlibrary.html">http://doc.qt.io/qt-5/sharedlibrary.html</a><br></div><div><br></div><div>The patch does that, and now the example links with the library just fine. The kImageAnnotatorExport.h header defines the macro, the compile definition is set for the shared library target in the CMakeLists.txt. I guess you'll  have to do the same for all classes used by the unit tests, no sure of the Qt development practices.</div><div><br></div><div>I also reworked your CMake files a bit. I am sending a single patch, though. Sorry.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">El mar., 21 de ago. de 2018 a la(s) 14:29, Eric Noulard (<a href="mailto:eric.noulard@gmail.com" target="_blank">eric.noulard@gmail.com</a>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">Le lun. 20 août 2018 à 19:05, Damir Porobic <<a href="mailto:damir_porobic@live.com" target="_blank">damir_porobic@live.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir="ltr">
<div id="m_2941313824199028209m_-7251925163260502270gmail-m_-1091032348120381152divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p style="margin-top:0px;margin-bottom:0px">Hi Eric,</p>
<p style="margin-top:0px;margin-bottom:0px"><br>
</p>
<p style="margin-top:0px;margin-bottom:0px">yes, this is the project. I have pushed my current state to this branch
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_DamirPorobic_kImageAnnotator_tree_sharedLibTestBranch&d=DwMFaQ&c=lz9TcOasaINaaC3U7FbMev2lsutwpI4--09aP8Lu18s&r=8hmSv9ww5s9qu3iT8h5WMi8-YcKXaJvelxT3fMih7S4&m=r4LA5jjr_jrRNhddqyy5IsuqRRwHEPCwRMFbxoU1ChI&s=j_vYMAeNlkSJPzPWt5eGGRXiqm4RocWUGgyctA8SGE4&e=" class="m_2941313824199028209m_-7251925163260502270gmail-m_-1091032348120381152OWAAutoLink" id="m_2941313824199028209m_-7251925163260502270gmail-m_-1091032348120381152LPlnk669383" target="_blank">
https://github.com/DamirPorobic/kImageAnnotator/tree/sharedLibTestBranch</a><br>
</p>
<br>
<p style="margin-top:0px;margin-bottom:0px">I've tried also without the generate_export_headers (cleaned everything up before trying out) but I get the same result.
<br>
</p>
<p style="margin-top:0px;margin-bottom:0px"><br>
</p>
<p style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0);font-family:Consolas,Courier,monospace;font-size:16px;background-color:rgb(255,255,255);float:none;display:inline">KImageAnnotator::</span><span style="color:rgb(0,0,0);font-family:Consolas,Courier,monospace;font-size:16px;background-color:rgb(255,255,255);float:none;display:inline">KImageAnnotator(QPixmap
 const&)<span style="font-family:Calibri,Helvetica,sans-serif">should be exposed by the handwritten file, that's true, I think I got something mixed up there and I don't actually need the
<span>generate_export_headers</span>, but as said, even without the line, it's not working.
<br></span></span></p></div></div></blockquote><div><br></div><div>I'm quite lost with the file layout.</div><div><br></div><div>in example/main.cpp you do:</div><div>#include <kImageAnnotator/KImageAnnotator.h></div><div>so I guess you expect that </div><div>target_link_libraries(kImageAnnotator-example PRIVATE kImageAnnotator::kImageAnnotator)<br></div><div><br></div><div>will bring you the include path to "kImageAnnotator/KImageAnnotator.h" along with the [imported] target</div><div><br></div><div>in your main tree (not in example) there is a trick because you did:</div><div><br></div><div>add_library(kImageAnnotator::kImageAnnotator ALIAS kImageAnnotator)<br></div><div><br></div><div>and then in the test directory you do:</div><div><br></div><div>target_link_libraries(${UnitTestName} Qt5::Test kimageannotator_LIB)<br></div><div><br></div><div>with </div><div><br></div><div>add_library(kimageannotator_LIB STATIC ${kimageannotator_SRCS})<br></div><div><br></div><div>so AFAIU you compile your kImageAnnotator library twice. Once for building the target you expect to use in example/ subdir</div><div>and another time as a STATIC lib for the unit test. So the unit test is not linking to the same object lib at all ??</div><div><br></div><div>I am not used to KDE development but all this seems very fuzzy to me.</div><div><br></div><div>May be you could get more precise help from people who know better about KDE dev and the specific CMake machinery that comes along </div><div>like ECM (<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_KDE_extra-2Dcmake-2Dmodules&d=DwMFaQ&c=lz9TcOasaINaaC3U7FbMev2lsutwpI4--09aP8Lu18s&r=8hmSv9ww5s9qu3iT8h5WMi8-YcKXaJvelxT3fMih7S4&m=r4LA5jjr_jrRNhddqyy5IsuqRRwHEPCwRMFbxoU1ChI&s=LaNKLek4ewlsoy7ECnW4qRmkBAAVUeo6iTSFqsT9ACo&e=" target="_blank">https://github.com/KDE/extra-cmake-modules</a>) you seems to be using.</div></div><div><br></div>-- <br><div dir="ltr" class="m_2941313824199028209m_-7251925163260502270gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_2941313824199028209gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div style="font-size:small;font-family:arial">Sebastian Mancilla Matta</div><div style="font-size:small;font-family:arial">CCTVal, UTFSM</div><div style="font-size:small;font-family:arial">Valparaíso, Chile</div></div></div>