<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">Le mer. 15 août 2018 à 10:32, Damir Porobic <<a href="mailto:damir_porobic@live.com">damir_porobic@live.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div id="m_-1589050174249929678divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,"EmojiFont","Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p style="margin-top:0;margin-bottom:0">Hi Folks,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">I'm trying to write a shared library and run into an issue where I can't find any clues to where the problem is.
<br>
<br>
I have a project with following structure:</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><span style="font-family:Consolas,Courier,monospace">src/</span></p>
<span style="font-family:Consolas,Courier,monospace"></span>
<p style="margin-top:0;margin-bottom:0"><span style="font-family:Consolas,Courier,monospace">    dir1/</span></p>
<span style="font-family:Consolas,Courier,monospace"></span>
<p style="margin-top:0;margin-bottom:0"><span style="font-family:Consolas,Courier,monospace">        file1.h</span><br>
<span style="font-family:Consolas,Courier,monospace"></span></p>
<span style="font-family:Consolas,Courier,monospace"></span>
<p style="margin-top:0;margin-bottom:0"><span style="font-family:Consolas,Courier,monospace">        file1.cpp</span></p>
<span style="font-family:Consolas,Courier,monospace"></span>
<p style="margin-top:0;margin-bottom:0"><span></span></p>
<span style="font-family:Consolas,Courier,monospace"></span>
<p style="margin-top:0;margin-bottom:0"><span style="font-family:Consolas,Courier,monospace">    dir2/</span></p>
<span style="font-family:Consolas,Courier,monospace"></span>
<p style="margin-top:0;margin-bottom:0"><span style="font-family:Consolas,Courier,monospace">        file2.h</span><br>
<span style="font-family:Consolas,Courier,monospace"></span></p>
<span style="font-family:Consolas,Courier,monospace"></span><span style="font-family:Consolas,Courier,monospace">        file2.cpp</span>
<p></p>
<p style="margin-top:0;margin-bottom:0"><span><span><br>
</span></span></p>
<p style="margin-top:0;margin-bottom:0"><span><span><br>
</span></span></p>
<p style="margin-top:0;margin-bottom:0"><span><span>Now I have this CMakeList:</span></span></p>
<p style="margin-top:0;margin-bottom:0"><span><span></span></span></p>
<div><span style="font-family:Consolas,Courier,monospace">cmake_minimum_required(VERSION 3.5)</span><br>
<span style="font-family:Consolas,Courier,monospace"></span><br>
<span style="font-family:Consolas,Courier,monospace">project(kImageAnnotator VERSION 0.0.1 LANGUAGES CXX)</span></div>
<span style="font-family:Consolas,Courier,monospace"></span><br>
<span style="font-family:Consolas,Courier,monospace"></span>
<p></p>
<span style="font-family:Consolas,Courier,monospace"></span>
<p style="margin-top:0;margin-bottom:0"><span><span><span style="font-family:Consolas,Courier,monospace">...</span><br>
<span style="font-family:Consolas,Courier,monospace"></span></span></span></p>
<span style="font-family:Consolas,Courier,monospace"></span>
<p style="margin-top:0;margin-bottom:0"><span><span style="font-family:Consolas,Courier,monospace"><br>
</span></span></p>
<span style="font-family:Consolas,Courier,monospace"></span>
<p style="margin-top:0;margin-bottom:0"><span><span></span></span></p>
<span style="font-family:Consolas,Courier,monospace"></span>
<div><span style="font-family:Consolas,Courier,monospace">add_library(${PROJECT_NAME} SHARED ${kimageannotator_SRCS})</span><br>
<span style="font-family:Consolas,Courier,monospace">target_link_libraries(${PROJECT_NAME} Qt5::Widgets KF5::CoreAddons KF5::I18n KF5::WidgetsAddons)</span><br>
<span style="font-family:Consolas,Courier,monospace"></span><br>
<span style="font-family:Consolas,Courier,monospace">target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include>)</span><br>
<span style="font-family:Consolas,Courier,monospace"></span><br>
<span style="font-family:Consolas,Courier,monospace">set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION 1)</span><br>
<span style="font-family:Consolas,Courier,monospace"></span><br>
<span style="font-family:Consolas,Courier,monospace">set(kimageannotator_CONFIG ${PROJECT_NAME}Config)</span><br>
<span style="font-family:Consolas,Courier,monospace"></span><br>
<span style="font-family:Consolas,Courier,monospace">install(TARGETS ${PROJECT_NAME} EXPORT ${kimageannotator_CONFIG}</span><br>
<span style="font-family:Consolas,Courier,monospace">        ARCHIVE  DESTINATION ${CMAKE_INSTALL_LIBDIR}</span><br>
<span style="font-family:Consolas,Courier,monospace">        LIBRARY  DESTINATION ${CMAKE_INSTALL_LIBDIR}</span><br>
<span style="font-family:Consolas,Courier,monospace">        RUNTIME  DESTINATION ${CMAKE_INSTALL_BINDIR})</span><br>
<span style="font-family:Consolas,Courier,monospace">install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})</span><br>
<span style="font-family:Consolas,Courier,monospace"></span><br>
<span style="font-family:Consolas,Courier,monospace">install(EXPORT ${kimageannotator_CONFIG} DESTINATION share/${kimageannotator_CONFIG}/cmake)</span><br>
<span style="font-family:Consolas,Courier,monospace"></span><br>
<span style="font-family:Consolas,Courier,monospace">export(TARGETS ${PROJECT_NAME} FILE ${kimageannotator_CONFIG}.cmake)</span></div>
<div><span><span><br>
</span></span></div>
<div><span><span><br>
</span></span></div>
<div><span><span>In another test project, I add the library like this:</span></span></div>
<div><span><span><span style="font-family:Consolas,Courier,monospace">...</span><br>
<span style="font-family:Consolas,Courier,monospace"></span></span></span></div>
<span style="font-family:Consolas,Courier,monospace"></span>
<div><span><span><span style="font-family:Consolas,Courier,monospace"></span>
<div><span style="font-family:Consolas,Courier,monospace">find_package(kImageAnnotator REQUIRED)</span><br>
<span style="font-family:Consolas,Courier,monospace"></span><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 Qt5::Widgets kImageAnnotator)</span></div>
<div><span><span></span></span><br>
</div>
</span></span></div>
<div><br>
</div>
<div>Now when I try to build my test project, I get this:</div>
<div><br>
</div>
<div>
<div><span style="font-family:Consolas,Courier,monospace">dporobic@linux ~/projects/testApp/build</span><br>
<span style="font-family:Consolas,Courier,monospace">$ cmake .. && make</span><br>
<span style="font-family:Consolas,Courier,monospace">-- Could not set up the appstream test. appstreamcli is missing.</span><br>
<span style="font-family:Consolas,Courier,monospace">-- Configuring done</span><br>
<span style="font-family:Consolas,Courier,monospace">-- Generating done</span><br>
<span style="font-family:Consolas,Courier,monospace">-- Build files have been written to: /home/dporobic/projects/testApp/build</span><br>
<span style="font-family:Consolas,Courier,monospace">[ 25%] Automatic moc for target testApp</span><br>
<span style="font-family:Consolas,Courier,monospace">[ 25%] Built target testApp_automoc</span><br>
<span style="font-family:Consolas,Courier,monospace">Scanning dependencies of target testApp</span><br>
<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">[ 75%] Building CXX object CMakeFiles/testApp.dir/testApp_automoc.cpp.o</span><br>
<span style="font-family:Consolas,Courier,monospace">[100%] Linking CXX executable testApp</span><br>
<span style="font-family:Consolas,Courier,monospace">CMakeFiles/testApp.dir/main.cpp.o: In function `main':</span><br>
<span style="font-family:Consolas,Courier,monospace">main.cpp:(.text+0x8e): undefined reference to `KImageAnnotator::KImageAnnotator(QPixmap const&)'</span><br>
<span style="font-family:Consolas,Courier,monospace">collect2: error: ld returned 1 exit status</span><br>
<span style="font-family:Consolas,Courier,monospace">CMakeFiles/testApp.dir/build.make:120: recipe for target 'testApp' failed</span><br>
<span style="font-family:Consolas,Courier,monospace">make[2]: *** [testApp] Error 1</span><br>
<span style="font-family:Consolas,Courier,monospace">CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/testApp.dir/all' failed</span><br>
<span style="font-family:Consolas,Courier,monospace">make[1]: *** [CMakeFiles/testApp.dir/all] Error 2</span><br>
<span style="font-family:Consolas,Courier,monospace">Makefile:94: recipe for target 'all' failed</span><br>
<span style="font-family:Consolas,Courier,monospace">make: *** [all] Error 2</span><br>
<br>
</div>
Any idea how I could/should troubleshoot such issue? <br></div></div></div></blockquote><div><br></div><div>Try to compile in verbose mode </div><div><br></div><div>make VERBOSE=1</div><div><br></div><div>and have a look at the culprit link line.</div><div>You should see the reference to your previously built shared lib.</div><div><br></div><div>Check whether this lib is where it should be (may be you didn't install it?)</div><div><br></div><div>then check which kImageAnnotatorConfig.cmake file is used by the testApp project in order to see if any</div><div>[wrong and not up to date] test & trial version of this file is lying around.</div><div> </div><div><br></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div></div>