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

Eric Noulard eric.noulard at gmail.com
Thu Nov 22 18:48:35 EST 2007


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

> 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 did have the time to craft a clean .def file from my project yet...

-- 
Erk


More information about the CMake mailing list