Hi Julien,

This lead me to another question:
In the wiki page, it is suggested to do the following:

#if defined (_WIN32)
 #if defined(MyLibrary_EXPORTS)
   #define  MYLIB_EXPORT __declspec(dllexport)
 #else
   #define  MYLIB_EXPORT __declspec(dllimport)
 #endif /* MyLibrary_EXPORTS */
#else /* defined (_WIN32) */
#define MYLIB_EXPORT
#endif

But in this piece of code, the case were we build static libraries under
windows is not handled. This means that we will import/export symbols
even if we build static libraries, and this seems to break the
compilation, leading to "undefine reference to declspec(dllimport) xxx"
when trying to link against the library. I did look at the export
sections of other libraries and they seem to handle this static case by
removing the __declspec(dllexport)/__declspec(dllimport). What is the
right thing to do here ?

For the PLplot project we use in addtion the macros USINGDLL and MAKINGDLL which are set if we use the shared library or make the shared library. But these macros only get defined for the shared case, so the PLDLLIMPEXP macros are defined to nothing in that case. Here is the code (which is more or less based on how the wxWidgets project did it)

#ifndef __PL_DLL_H
#define __PL_DLL_H

#ifdef USINGDLL
  #define USINGPLDLL
#endif

#if defined(WIN32)
  /* Visual C/C++, Borland, MinGW and Watcom */
#if defined(__VISUALC__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__GNUC__) || defined(__WATCOMC__)
    #define PLDLLEXPORT __declspec(dllexport)
    #define PLDLLIMPORT __declspec(dllimport)
  #else
    #define PLDLLEXPORT
    #define PLDLLIMPORT
  #endif
#elif defined(__CYGWIN__)
  #define PLDLLEXPORT __declspec(dllexport)
  #define PLDLLIMPORT __declspec(dllimport)
#endif

#ifndef PLDLLEXPORT
#    define PLDLLEXPORT
#    define PLDLLIMPORT
#endif

#if defined(MAKINGPLDLL)
  #define PLDLLIMPEXP PLDLLEXPORT
  #define PLDLLIMPEXP_DATA(type) PLDLLEXPORT type
#elif defined(USINGPLDLL)
  #define PLDLLIMPEXP PLDLLIMPORT
  #define PLDLLIMPEXP_DATA(type) PLDLLIMPORT type
#else
  #define PLDLLIMPEXP
  #define PLDLLIMPEXP_DATA(type) type
#endif

#endif /* __PL_DLL_H */

HTH,
Werner


--
Dr. Werner Smekal
Institut fuer Allgemeine Physik
Technische Universitaet Wien
Wiedner Hauptstr 8-10
A-1040 Wien
Austria

email: [EMAIL PROTECTED]
web: http://www.iap.tuwien.ac.at/~smekal
phone: +43-(0)1-58801-13463 (office), +43-(0)1-58801-13469 (laboratory)
fax: +43-(0)1-58801-13499

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to