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

Stephen Collyer scollyer at netspinner.co.uk
Fri Nov 23 04:53:23 EST 2007


Eric Noulard wrote:

> 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 {
> ...
> }

Yes.

> 2) or do you want to have
> 
> class Lib1 {
>  ...
> }
> but still have symbol exported?

No. You'll need *some* #define present, else there's no
way to insert the _declspec text.

> 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?

I've been thinking about it, and I'm not convinced it's even
possible due to the problem you pointed out. The problem is
that any LIB_EXPORTS variable would need to simultaneously
export in the exporting libary and import in the importing
library => impossible.

> 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...

I think the LIB_EXPORTS stuff is preferable to the .def file approach
though it certainly doesn't make life easy.

-- 
Regards

Steve Collyer
Netspinner Ltd


More information about the CMake mailing list