Nuand / bladeRF

bladeRF USB 3.0 Superspeed Software Defined Radio Source Code
http://nuand.com
Other
1.12k stars 452 forks source link

[libbladeRF] API_EXPORT should evaluate to dllexport only when building libbladeRF #479

Open jynik opened 8 years ago

jynik commented 8 years ago

The dllexport entries should only be used when building the libbladerf_shared target.

For other cases, these should be dllimport.

A compile-time definition should be used to switch between them.

jynik commented 8 years ago

As kindly pointed out to me, this only applies for the libbladerf_shared target.

If we added a libbladerf_static target, we'd need to ensure we have an empty API_EXPORT expansion.

gvanem commented 6 years ago

Still an open issue! How about this in libbladeRF.h:

#ifdef BLADERF_STATICLIB
  /* Use BladeRF as a static library */
  #define BLADERF_EXTERN   
#elif defined(_WIN32) || defined(__CYGWIN__)
    /* Defined when compiling 'host/libraries/libbladeRF/src/' .c-files */
  #if defined(BUILDING_BLADERF)
    #define BLADERF_EXTERN  __declspec(dllexport)
  #else
    #define BLADERF_EXTERN  __declspec(dllimport)
  #endif
#else
  #define BLADERF_EXTERN
#endif

And then replace API_EXPORT with BLADERF_EXTERN. A bit more intuitive IMHO. I'm not sure it's possible to use BladeRF as a static library. But it could certainly prevent a .DLL-hell.