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

Yogesh Marwaha yogeshm.007 at gmail.com
Thu Jul 10 02:49:28 EDT 2008


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/20080710/3c54f6b0/attachment.htm>


More information about the CMake mailing list