[CMake] Problems building a shared library

Ryan Pavlik rpavlik at iastate.edu
Thu May 27 11:55:11 EDT 2010


Your problem #1 sounds like you might not have the appropriate 
definitions set up in your headers on Windows to export symbols from a 
shared library - see this page for info: 
http://www.cmake.org/Wiki/BuildingWinDLL

On 05/27/2010 09:59 AM, Torri, Stephen CIV NSWCDD, W15 wrote:
> I am attempting to build a shared library as a project. In order to explain my project I will use a pseudo project with a similar setup. The library is called TruckInterface with four directories (Wheels, Engine, Frame and Truck). The directories Wheels, Engine and Frame are built as static libraries and Truck is a shared library to be installed.
>
> TruckInterface
>    |------- Wheels
>    |------- Engine
>    |------- Frame
>    |------- Truck
>
> In the CMakeLists.txt for Wheels, Engine and Frame I have followed the format below:
>
>    SET ( HEADERS ..list header files )
>    SET ( SOURCES ...list source files )
>
>    INCLUDE_DIRECTORIES ( ...other directory to look for headers in the project... )
>
>    add_library (<name>  STATIC ${SOURCES} ${HEADERS} )
>
> In the CMakeLists.txt for Truck I have
>
>    SET ( HEADERS ..list header files )
>    SET ( SOURCES ...list source files )
>
>    INCLUDE_DIRECTORIES ( ...other directory to look for headers in the project... )
>
>    add_library ( Truck SHARED ${SOURCES} ${HEADERS} )
>    link_libraries ( Wheels Engine Frame )
>
> Now my problems that I am coming across, some of which are not cmake's fault:
>
> 1. Undefined references even though the code has been declared for member functions
> 2. Unable to set global compiler flags in the CMakeLists in the TruckInterface directory
> 3. How to select when I want a debug versus a release build.
>
> My experience is using Automake/Autoconf on Linux and Visual Studio on Windows.
>
> I would appreciate help on points 2 and 3 but would like advice on how to debug point 1.
>
> Stephen
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>    

-- 
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik at iastate.edu
http://academic.cleardefinition.com
Internal VRAC/HCI Site: http://tinyurl.com/rpavlik



More information about the CMake mailing list