[CMake] Win32: exporting symbols for DLLs - simpler method ?

Christian Ehrlicher Ch.Ehrlicher at gmx.de
Fri Nov 23 00:39:19 EST 2007


Eric Noulard schrieb:
> 2007/11/23, Stephen Collyer <scollyer at netspinner.co.uk>:
>> Cmake seems to define, for each library that is built, a symbol
>> of the form <library>_EXPORTS, which can be used to set up
>> #defines for the __declspec(dllexport/dllimport) stuff that
>> Windows needs.
>>
>> However, this means that each library needs a specific symbol
>> to allow it to be built with the correct import/export spec e.g.
>>
>>
>> class LIB1_EXPORTS Lib1 {
>> ...
>> }
>>
>> class LIB2_EXPORTS Lib2 {
>> ...
>> }
>>
>> and so on. What I'd like to do is to have a single #define
>> (LIB_EXPORTS or something) that is set appropriately somehow.
> 
> What do you mean?
> 1) You want a single LIB_EXPORTS for all libs such that you may write:
> 
> class LIB_EXPORTS Lib1 {
>  ...
> }
> 
> class LIB_EXPORTS Lib2 {
> ...
> }
> 
> 2) or do you want to have
> 
> class Lib1 {
>  ...
> }
> but still have symbol exported?
> 
> I think 1) is possible if all classes are in the same lib, but
> may be this is obvious. In other cases if LIb1 is using LIb2
> the two libs cannot share the LIB_EXPORTS var because
> the using lib need dllimport while the other need dllexport?
> 
> 2) is possible if you use .def file instead of __declspec(dllexport/dllimport)
>     see e.g.
>     http://www.codeproject.com/dll/SimpleDllP3.asp
> 
This is the old way to export functions and imho very error-prone (you
have to change your function name on two places for proper export). Also
this does not work for linux.
You'll need a single #define FOO_EXPORT for every lib you create.

>> Is this possible ? I don't see how at the moment, but the
>> method I'm using at the moment is rather tedious and I'd like
>> to simplify it, if possible.
> 
> I'm interested in your problem too because I personnally
> would like to throw away those LIB_EXPORTS prefix from the source.
I don't understand this.


Christian

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
Url : http://public.kitware.com/pipermail/cmake/attachments/20071123/a7c32c28/signature.pgp


More information about the CMake mailing list