[CMake] Building shared libraries for KDE app

Andreas Pakulat apaku at gmx.de
Thu Jul 31 02:24:46 EDT 2008


On 30.07.08 22:49:25, David Boosalis wrote:
> I have had no trouble using cmake to build kde executables, but have been unable to use it successfully to build a shared library that my kde application uses.  
> 
> The library builds fine but it is missing all the symbols from my source files.  When I use qmake to build the library it all works the symobls are all there and everything works fine.

This usually means you didn't export any of your symbols. KDE uses gcc's
visibility feature to export only those symbols that are part of the
public API. For that to work you need something like the following in a
header:

#ifndef INTERFACESEXPORT_H
#define INTERFACESEXPORT_H

/* needed for KDE_EXPORT macros */
#include <kdemacros.h>

#ifndef KDEVPLATFORMINTERFACES_EXPORT
# ifdef MAKE_KDEVPLATFORMINTERFACES_LIB
#  define KDEVPLATFORMINTERFACES_EXPORT KDE_EXPORT
# else
#  define KDEVPLATFORMINTERFACES_EXPORT KDE_IMPORT
# endif
#endif

#endif

And then prefix any class you want to export with (in this example)
KDEVPLATFORMINTERFACES_EXPORT (after "class").

CMake sets the MAKE_KDEVPLATFORMINTERFACES_LIB define when building the
library (the general form is MAKE_<targetname>_LIB) and then KDE_EXPORT
is automtaically set to the right export definition depending on your
platform. KDE_IMPORT is only interesting on windows, it basically tells
the compiler to import the symbols of that library into the app where
they're used.

Unfortunately I don't know if there's a tutorial for this, but if there
is its probably on techbase.kde.org.

Andreas

-- 
Expect a letter from a friend who will ask a favor of you.


More information about the CMake mailing list