[CMake] Creating libraries (DLL) in windows

Hendrik Sattler post at hendrik-sattler.de
Fri Aug 1 19:06:43 EDT 2008


Am Samstag, 2. August 2008 00:41:11 schrieb Leopold Palomo Avellaneda:
> I understand that you have to add:
>
>  class MYLIB_EXPORT MyClass
>
> for all the classes,
> but also for the structs , and functions?

If a class is exported,  its member functions also get exported. For 
non-member function, this must also be added. Structs and classes are roughly 
the same in C++ (different initialisation) but unless they include functions 
(not function pointers), the do not need to be exported (you don't link to 
it).

BTW: With gcc >= 4 on linux, you may also want to use
#define MYLIB_EXPORT __attribute__((visibility("default")))
and compile with -fvisibility=hidden. That allows to not export symbols for 
internal classes and it's faster at runtime.

HS


More information about the CMake mailing list