[CMake] shared libraries .lib .dll
Stefan Buschmann
s_buschmann at gmx.de
Thu Jun 19 13:31:09 EDT 2008
Pierre Malarme schrieb:
> hi,
> i've taken your advice on the __declspec stuff and test it on a hello
> world project. i do have a .lib now but with a warning
> "
> hello.cxx
>
> ..\..\CMakeExample\Hello\hello.cxx(5) : warning C4273: 'Hello::Print'
> : inconsistent dll linkage
>
> h:\workspace\cmakeexample\cmakeexample\hello\hello.h(18) : see
> previous definition of 'Print'
>
> is that normal?
>
This means that you still have something wrong with your __declspec
definitions or the way that you include the library into other projects.
SPCK_BASE_EXPORT must be __declspec(dllexport) when you build the shared
library itself
SPCK_BASE_EXPORT must be __declspec(dllimport) when you import headers
from that library into other projects.
This is handled correctly the way Martin has posted it.
For this to work, Base_EXPORTS must be set only when you build the
shared library, and in must *not* be set in all other projects that link
against the library. So have a look at where you define Base_EXPORTS,
e.g. by adding ADD_DEFINITIONS(-DBase_Exports) in your CMakeLists.txt or
by #define Base_EXPORTS inside a header file. CMake usually adds this
automatically for DLL targets, so it should be right when you build the
DLL. Take care that it is not set in any projects that use the library
and that you don't define it in any header file of the library.
Hope this helps...
Stefan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080619/68c63f09/attachment.htm>
More information about the CMake
mailing list