<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Thanks you <span>Sebastián</span> for finding the issue and fixing the CMake, probably would have never found out that it was set to private.
<br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">The kImageAnnotator-example is working now as expected. Do I need something else, except installing the lib, in order to use it in different projects? I've created a second project which is identical to the
<span>kImageAnnotator-example</span> but I get following when I try to build it:</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div><span style="font-family: Consolas, Courier, monospace;">[ 50%] Building CXX object CMakeFiles/testApp.dir/main.cpp.o</span><br>
<span style="font-family: Consolas, Courier, monospace;">In file included from /home/dporobic/projects/testApp/main.cpp:2:0:</span><br>
<span style="font-family: Consolas, Courier, monospace;">/usr/local/include/kImageAnnotator/KImageAnnotator.h:31:35: fatal error: KImageAnnotatorExport.h: No such file or directory</span><br>
<span style="font-family: Consolas, Courier, monospace;"> #include <KImageAnnotatorExport.h></span></div>
<div><span style="font-family: Consolas, Courier, monospace;"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"></font>
<div>                                   ^<br>
compilation terminated.<br>
<br>
</div>
</span></div>
<p></p>
<p style="margin-top:0;margin-bottom:0">The includes look like this:</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div><span style="font-family: Consolas, Courier, monospace;">#include <QApplication></span><br>
<span style="font-family: Consolas, Courier, monospace;">#include <kImageAnnotator/KImageAnnotator.h></span></div>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">And the CMake looks like this:</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div><span style="font-family: Consolas, Courier, monospace;">find_package(kImageAnnotator REQUIRED)</span><br>
<br>
<span style="font-family: Consolas, Courier, monospace;">add_executable(testApp main.cpp)</span><br>
<span style="font-family: Consolas, Courier, monospace;">target_link_libraries(testApp kImageAnnotator)</span></div>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Am I missing something again?<br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<br>
<div style="color: rgb(49, 54, 59);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Sebastián Mancilla <smancill@jlab.org><br>
<b>Sent:</b> Wednesday, August 22, 2018 00:51<br>
<b>To:</b> Eric Noulard<br>
<b>Cc:</b> Damir Porobic; cmake@cmake.org<br>
<b>Subject:</b> Re: [CMake] Problem with creating shared library</font>
<div> </div>
</div>
<meta content="text/html; charset=utf-8">
<div>
<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" id="LPlnk998028" class="OWAAutoLink" previewremoved="true">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" id="LPlnk324825" class="OWAAutoLink" previewremoved="true">http://doc.qt.io/qt-5/sharedlibra<br>
<div id="LPBorder_GT_15349676105240.2538911332902525" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_15349676105220.1114939049832483" style="width: 90%; background-color: rgb(255, 255, 255); " role="presentation" cellspacing="0">
<tbody>
<tr style="border-spacing: 0px;" valign="top">
<td id="TextCell_15349676105220.977705330934571" style="vertical-align: top; position: relative;" colspan="2">
<div id="LPRemovePreviewContainer_15349676105220.2907840355011231"></div>
<div id="LPTitle_15349676105220.08623757792943798" style="top: 0px; color: rgb(0, 120, 215); font-weight: 400; font-size: 21px; font-family: "wf_segoe-ui_light", "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; line-height: 21px;">
<a id="LPUrlAnchor_15349676105220.38796385883178475" style="text-decoration: none;" href="https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application" target="_blank">How to create a library with Qt and use it in an application</a></div>
<div id="LPMetadata_15349676105230.5626165396632882" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: 400; font-family: "wf_segoe-ui_normal", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 14px;">
wiki.qt.io</div>
<div id="LPDescription_15349676105240.4457276471544921" style="display: block; color: rgb(102, 102, 102); font-weight: 400; font-family: "wf_segoe-ui_normal", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 20px; max-height: 100px; overflow: hidden;">
This tutorial illustrates different approaches for using a custom library in your application on Windows. The first part explains how to create a shared library and how to link against it in your application. The second part is about creating and using a static
 library. Creating a shared library ...</div>
</td>
</tr>
</tbody>
</table>
</div>
ry.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="x_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" id="LPlnk457743" class="OWAAutoLink" previewremoved="true">eric.noulard@gmail.com</a>) escribió:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr"><br>
<br>
<div class="x_gmail_quote">
<div dir="ltr">Le lun. 20 août 2018 à 19:05, Damir Porobic <<a href="mailto:damir_porobic@live.com" target="_blank" id="LPlnk963908" class="OWAAutoLink" previewremoved="true">damir_porobic@live.com</a>> a écrit :<br>
</div>
<blockquote class="x_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="x_m_2941313824199028209m_-7251925163260502270gmail-m_-1091032348120381152divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif">
<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="x_m_2941313824199028209m_-7251925163260502270gmail-m_-1091032348120381152OWAAutoLink OWAAutoLink" id="LPlnk818642" target="_blank" previewremoved="true">
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" id="LPlnk13386" class="OWAAutoLink" previewremoved="true">https://github.com/KDE/extra-cmake-modules</a>)
 you seems to be using.</div>
</div>
<div><br>
</div>
-- <br>
<div dir="ltr" class="x_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="x_m_2941313824199028209gmail_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>
</div>
</div>
</div>
</body>
</html>