Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix dllexport declspec for static/DLL usage on Windows #133

Merged
merged 1 commit into from

4 participants

Timothee "TTimo" Besset AJ Lewis pijyoi Pieter Hintjens
Timothee "TTimo" Besset
Collaborator

I don't think the dllimport is intended here. It causes external programs using the header to try and link the symbols only from a DLL, breaking static linking. Programs that dynamically link against czmq DLL should define DLL_EXPORT and will be fine.

Timothee "TTimo" Besset TTimo I don't think the dllimport is intended here. It causes external prog…
…rams using the header to try and link the symbols only from a DLL, breaking static linking. Programs that dynamically link against czmq DLL should define DLL_EXPORT and will be fine.
4f4937c
Pieter Hintjens hintjens merged commit a980486 into from
AJ Lewis
Collaborator

It's still not quite right...if DLL_EXPORT is defined, you get __declspec(dllexport), not __declspec(dllimport) and the dllimport is required for linking with the DLL version of czmq.

I've got another couple changes for the czmq.sln and project files anyway, so I'll see if I can get this fixed as well.

pijyoi
Collaborator
Timothee "TTimo" Besset
Collaborator
pijyoi
Collaborator
AJ Lewis
Collaborator

I've always had to use __declspec(dllimport) for the code using the library, but only for the header of the DLL.

#   if defined (_WINDLL)
#       if defined LIBNAME_EXPORTS
#        define LIBNAME_EXPORT __declspec(dllexport)
#       else
#        define LIBNAME_EXPORT __declspec(dllimport)
#       endif
#  else
#   define LIB_EXPORT extern
#  endif

LIBNAME_EXPORTS void myfunc(void);

To your second point, I'm fairly certain we can't easily encapsulate the libzmq DLL in the czmq DLL, and I'd rather not see that done. But then, I'm used to SONAME conventions in *NIX and windows doesn't seem to behave well WRT library versioning.

AJ Lewis
Collaborator

pijyoi, the problem is there isn't a way to shut off __descspec(dllimport) for static linking. There needs to be something like the above quoted code for it to work properly. I'll send a patch shortly.

Timothee "TTimo" Besset
Collaborator
pijyoi
Collaborator
AJ Lewis
Collaborator

Personally, I think checking for the _WINDLL define (which is setup when building as a DLL) is more elegant, but will that cause problems for people using MinGW or other non-Visual Studio setups?

AJ Lewis
Collaborator

Pull request is sent with a fix (#134). See if that works for y'all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 7, 2013
  1. Timothee "TTimo" Besset

    I don't think the dllimport is intended here. It causes external prog…

    TTimo authored
    …rams using the header to try and link the symbols only from a DLL, breaking static linking. Programs that dynamically link against czmq DLL should define DLL_EXPORT and will be fine.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  include/czmq_prelude.h
2  include/czmq_prelude.h
View
@@ -467,7 +467,7 @@ static inline void *
# if defined DLL_EXPORT
# define CZMQ_EXPORT __declspec(dllexport)
# else
-# define CZMQ_EXPORT __declspec(dllimport)
+# define CZMQ_EXPORT
# endif
#else
# define CZMQ_EXPORT
Something went wrong with that request. Please try again.