[CMake] import/export and DLL's

Totte Karlsson totte at dunescientific.com
Tue Dec 6 04:42:02 EST 2011


Thanks for feedback
>
> You misunderstand and misuse the DEFINE_SYMBOL property. All the
> IMPORT_X_DLL symbols are wrong, you have to remove them.

But when building the B, and C dll the import symbols need to be defined 
somehow. See my export/import header below.

CMake will only
> add the DEFINE_SYMBOL when *building* the specified target, and
> otherwise just leave it away.
Not sure I understand.


> So, in your code you do something like this:
>
> #ifdef EXPORT_A_DLL
> #define A_API __declspec(dllexport)
> #else
> #define A_API __declspec(dllimport)
> #endif
>
I'll try to see if that works. Right now I do have an exporter/importer header 
and it is more complex and looks like (for a target "COMMON"):
#if defined(EXPORT_COMMON_DLL)
	#define MTK_COMMON __declspec(dllexport)
#elif defined(IMPORT_COMMON_DLL)
	#define MTK_COMMON __declspec(dllimport)
#elif defined(EXPORT_COMMON_PKG)
	#define MTK_COMMON __declspec(package)
#elif defined(IMPORT_COMMON_PKG)
	#define MTK_COMMON __declspec(package)
#else
	#define MTK_COMMON
#endif

Is the problem perhaps that the EXPORT_COMMON_DLL defined symbol is not 
"undeffed" so when the B DLL need to Import from A, it can't?

TK
> For B and C the definitions are analogous.
>
> HTH
>
> Michael
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list