Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

Merged
merged 1 commit into from about 1 year ago

4 participants

Timothee "TTimo" Besset AJ Lewis pijyoi Pieter Hintjens
Timothee "TTimo" Besset
Collaborator
TTimo commented April 08, 2013

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 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 April 08, 2013
Pieter Hintjens hintjens closed this April 08, 2013
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
TTimo commented April 08, 2013
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
TTimo commented April 08, 2013
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

Showing 1 unique commit by 1 author.

Apr 07, 2013
Timothee "TTimo" Besset 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
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  include/czmq_prelude.h
2  include/czmq_prelude.h
@@ -467,7 +467,7 @@ static inline void *
467 467
 #   if defined DLL_EXPORT
468 468
 #       define CZMQ_EXPORT __declspec(dllexport)
469 469
 #   else
470  
-#       define CZMQ_EXPORT __declspec(dllimport)
  470
+#       define CZMQ_EXPORT
471 471
 #   endif
472 472
 #else
473 473
 #   define CZMQ_EXPORT
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.