[CMake] Problem linking to shared library (inside project) after upgrade to cmake 2.6

Yogesh Marwaha yogeshm.007 at gmail.com
Sat Jul 12 07:21:01 EDT 2008


Hello, can someone figure out what I'm doing wrong.
Here is the output I get when I attempt to compile: -
=================================
yogesh at linux-sm3q:~/gravity/New> make
Scanning dependencies of target GravityCore
[ 91%] Built target GravityCore
Scanning dependencies of target Gravity
Linking CXX executable Gravity
CMakeFiles/Gravity.dir/main.o: In function `main':
/home/yogesh/gravity/app/main.cpp:10: undefined reference to
`GApplication::GApplication()'
/home/yogesh/gravity/app/main.cpp:12: undefined reference to
`Gravity::self()'
/home/yogesh/gravity/app/main.cpp:12: undefined reference to
`Gravity::gUIInterfaceManager() const'
/home/yogesh/gravity/app/main.cpp:13: undefined reference to
`GApplication::~GApplication()'
collect2: ld returned 1 exit status
make[2]: *** [app/Gravity] Error 1
make[1]: *** [app/CMakeFiles/Gravity.dir/all] Error 2
make: *** [all] Error 2
=================================

Thanks,

-- 
Yogesh M


2008/7/10 Yogesh Marwaha <yogeshm.007 at gmail.com>:

> My project used to compile & link fine with cmake 2.4 on openSUSE 10.3.
> Recently I upgraded to openSUSE 11, hence cmake 2.6, and now error is being
> shown at link time.
>
> The project is mainly split in 3 sub-folders: -
> 1. library; generates GravityCore shared library
> 2. app; generates an executable which uses (links to) the GravityCore
> shared library.
> 3. modules; collection of shared libraries (read plugins) which links to
> GravityCore (and loaded by app)
>
> Error is shown at the time of linking of app/modules. The linker complains
> of unresolved symbols (which are in library).
>
> Nothing has changed in the project since the upgrade and one thing to note
> is that GravityCore library file which earlier used to be about 10 MB is now
> around 6 MB. And when it built GravityCore as static library, just to see
> the results, the project compiled and linked fine.
>
> Please help me to resolve the issue.
>
> Here are cmakelists.txt files from my project for your perusal: -
>
> CMAKELISTS.TXT IN BASE FOLDER
> =============================
> project (Gravity)
> cmake_minimum_required (VERSION 2.4.0)
> set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/"
> "/usr/share/kde4/apps/cmake/modules")
> find_package (Taglib REQUIRED)
> find_package (Qt4 REQUIRED)
> find_package (KDE4 REQUIRED)
> add_subdirectory (library)
> add_subdirectory (app)
> add_subdirectory (modules)
> ----------------------------
>
> CMAKELISTS.TXT IN library FOLDER
> ================================
> set (QT_USE_QTXML TRUE)
> include (${QT_USE_FILE})
> include_directories (${TAGLIB_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
> ${KDE4_INCLUDES})
> set (GravityCore_SRCS
>   gcollection.cpp
>   gcollectionholder.cpp
>   ...
>   ...
>   sqliteengine.cpp
> )
> set (GravityCore_MOCS
>   gcollection.cpp
>   gcollectionholder.cpp
>   ...
>   ...
>   playlistcontainer.cpp
> )
> qt4_automoc(${GravityCore_MOCS})
>
> add_library (GravityCore SHARED ${GravityCore_SRCS})
>
> target_link_libraries (GravityCore ${QT_LIBRARIES} ${QT_QTXML_LIBRARIES}
> ${TAGLIB_LIBRARIES} ${KDE4_PHONON_LIBS} ${KDE4_SOLID_LIBS}
> ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} sqlite3)
>
> install(TARGETS GravityCore DESTINATION lib)
> install(FILES gravity_userinterface_plugin.desktop DESTINATION
> share/kde4/servicetypes)
> --------------------------------
>
>
> CMAKELISTS.TXT IN app FOLDER
> ============================
> include (${QT_USE_FILE})
> include_directories (${KDE4_INCLUDES} ${Gravity_SOURCE_DIR}/library)
> set (GravityApp_SRCS
>   main.cpp
> )
> link_directories (${Gravity_BINARY_DIR}/library)
> add_executable (Gravity ${GravityApp_SRCS})
> target_link_libraries (Gravity GravityCore)
> install(TARGETS Gravity DESTINATION bin)
> install(FILES Gravity.desktop DESTINATION share/applications/kde4)
> ----------------------------
>
>
> CMAKELISTS.TXT IN modules FOLDER
> ================================
> include (${QT_USE_FILE})
> include_directories (${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDES}
> ${Gravity_SOURCE_DIR}/library)
> set (GravityBasicUIPlugin_SRCS
>   gravitymainwindow.cpp
>   playerwidget.cpp
>   gscrollwidget.cpp
> )
> set (GravityBasicUIPlugin_MOCS
>   gravitymainwindow.cpp
>   playerwidget.cpp
>   gscrollwidget.cpp
> )
> qt4_automoc(${GravityBasicUIPlugin_MOCS})
> link_directories (${Gravity_BINARY_DIR}/library)
> add_library (GravityBasicUIPlugin MODULE ${GravityBasicUIPlugin_SRCS})
>
> target_link_libraries (GravityBasicUIPlugin GravityCore)
>
> install(TARGETS GravityBasicUIPlugin DESTINATION lib/kde4)
> install(FILES gravity_basic_userinterface.desktop DESTINATION
> share/kde4/services)
> --------------------------------
>
> Thanks for any help offered,
>
> Yogesh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080712/20758df8/attachment.htm>


More information about the CMake mailing list