2012/9/12 Sandro Andrade : > On Wed, Sep 12, 2012 at 7:13 PM, Luiz Rom=E1rio Santana Rios > wrote: >> 2012/9/11 Sandro Andrade : >>> On Mon, Sep 10, 2012 at 9:29 PM, Luiz Rom=E1rio Santana Rios >>> wrote: >>>> Hi. >>>> >>>> So, I recently started to write a "pluggable" library. You can check i= t from >>>> here: >>>> http://quickgit.kde.org/index.php?p=3Dscratch%2Fromariorios%2Flibkodri= .git&a=3Dsummary >>>> . >>>> >>>> It was all good until I tried to write a dummy plugin for it (currently >>>> available in the dummy_packagesource branch of the above repo). It was= a >>>> pretty trivial plugin, it just implemented the pure virtual functions = from >>>> the interface. But I kept getting this error: >>>> >>>> [100%] Building CXX object >>>> packagesources/CMakeFiles/kodri_packagesource_dummy.dir/dummypackageso= urce.o >>>> In file included from >>>> /home/kde4/kde-master-install/include/kodri/abstractpackagesource.h:29= :0, >>>> from >>>> /home/kde4/kdesrc/libkodri/packagesources/dummypackagesource.h:23, >>>> from >>>> /home/kde4/kdesrc/libkodri/packagesources/dummypackagesource.cpp:20: >>>> /home/kde4/kde-master-install/include/kodri/version.h:31:28: error: ex= pected >>>> initializer before =91:=92 token >>>> /home/kde4/kdesrc/libkodri/packagesources/dummypackagesource.cpp:1381:= 1: >>>> error: expected =91}=92 at end of input >>>> make[2]: ** >>>> [packagesources/CMakeFiles/kodri_packagesource_dummy.dir/dummypackages= ource.o] >>>> Erro 1 >>>> make[1]: ** [packagesources/CMakeFiles/kodri_packagesource_dummy.dir/a= ll] >>>> Erro 2 >>>> make: ** [all] Erro 2 >>>> >>>> I then suspected that the KODRI_EXPORT macro wasn't being expanded whe= n the >>>> exported classes were included outside the library. Then I manually re= placed >>>> KODRI_EXPORT by __attribute__ ((visibility("default")) and, as I suspe= cted, >>>> the error vanished. Of course, other errors appeared afterwards, but I= 'll >>>> try to solve them later. >>>> >>>> My question is: why doesn't the macro expand? I followed the techbase >>>> tutorial on creating new libraries step by step, so I can't see where = I got >>>> it wrong. >>> >>> It doesn't expand because you have a wrong kodri_export.h: >>> >>> #ifndef KODRI_EXPORT >>> # if defined(MAKE_KODRI_LIB) >>> # define KODRI_EXPORT KDE_EXPORT >>> # else >>> # define KODRI_IMPORT KDE_IMPORT >>> # endif >>> #endif >>> >>> It should be: >>> >>> #ifndef KODRI_EXPORT >>> # if defined(MAKE_KODRI_LIB) >>> # define KODRI_EXPORT KDE_EXPORT >>> # else >>> # define KODRI_EXPORT KDE_IMPORT >>> # endif >>> #endif >> Whoops... >> >> Thank you, I'd take ages to notice that. >> >>> >>> Besides that, I'd rearrange CMakeLists.txt's in order to have lib and >>> plugin as sibling sub-CMakeLists.txt (or even as separated projects). >>> Find a possible refactoring at: >>> >>> http://d01.megashares.com/dl/dTjbpUz/libkodri-refactored.tar.gz >> I'll take a look at it. >> >>> >>> Plugin's CMakeLists.txt also contains some errors: >>> >>> target_link_libraries(kodri_packagesource_dummy ${KDE4_CORE_LIBS} >>> ${KDE4_KODRI_LIBS}) >>> >>> The correct var is ${KDE4_KDECORE_LIBS}. ${KDE4_KODRI_LIBS} isn't >>> automatically generated >>> at all. You should write a cmake module in order to detect your library. >> I have this in CMakeLists.txt:37: >> >> install(TARGETS kodri EXPORT kdelibsLibraryTargets >> ${INSTALL_TARGETS_DEFAULT_ARGS}) >> >> Doesn't it do the job? > > Not completely. If you try to build the plugin in an environment which > doesn't have your > lib installed, cmake won't detect that. You'll get only a compiler error. > > See for example: > https://projects.kde.org/projects/extragear/kdevelop/kdevelop/repository/= revisions/master/entry/cmake/modules/FindKDevPlatform.cmake True. Now I remember seeing something like this when taking a look at KTelepathy. Thanks. > > That will allow you to use a: > > find_package(Kodri 1.0.0 REQUIRED) > > in the plugin's CMakeLists.txt. If it's not found cmake will early detect= that. > > []s, > Sandro > >> >> Thanks for the pointers. >> >>> >>> Sandro >>> >>>> >>>> Best regards. >>>> >>>> -- >>>> Luiz Rom=E1rio Santana Rios >>>> >>>> >>>>>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubs= cribe >>>>>> << >>>> >>> >>>>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubsc= ribe << >> >> >> >> -- >> Luiz Rom=E1rio Santana Rios >> >>>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscr= ibe << > >>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscri= be << -- = Luiz Rom=E1rio Santana Rios >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscrib= e <<