Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking with libzmqpp fails on windows / mingw-w64. #192

Closed
Smasherr opened this issue May 2, 2017 · 5 comments
Closed

Linking with libzmqpp fails on windows / mingw-w64. #192

Smasherr opened this issue May 2, 2017 · 5 comments

Comments

@Smasherr
Copy link
Contributor

Smasherr commented May 2, 2017

I am trying to create a proxy object in my code:

zmqpp::socket dealer(ctx, zmqpp::socket_type::xrequest);
zmqpp::socket router(ctx, zmqpp::socket_type::xreply);
router.bind("tcp://*:1234");
dealer.bind("inproc://workers");
zmqpp::proxy(router, dealer);

That linking error message appears: undefined reference to 'zmqpp::proxy::proxy(zmqpp::socket&, zmqpp::socket&)'

If I change the proxy class definition as following:

class __declspec(dllexport) proxy

and rebuild zmpqq, my binary gets linked well.

I am using the latest sources of libzmq and zmpqq pulled from git on msys2 with mingw-w64, cmake 3.8 and gcc 6.3.0.

@bluca
Copy link
Member

bluca commented May 3, 2017

What's missing is the ZMQPP_EXPORT attribute, eg:

class proxy

should probably be

class ZMQPP_EXPORT proxy

https://github.com/zeromq/zmqpp/blob/develop/src/zmqpp/proxy.hpp#L27

Since it affects you, could you please test it and send a PR if this works for you? Thanks!

@Smasherr
Copy link
Contributor Author

Smasherr commented May 3, 2017

I already tried it and I should have mentioned that, sorry. With ZMQPP_EXPORT i get another error: undefined reference to '__imp__ZN5zmqpp5proxyC1ERNS_6socketES2_'. This is because ZMQPP_EXPORT evaluates to __declspec(dllimport) for me for some reason, my IDE reveals me the following view on zmqpp_export.h, if I request a declaration of this ZMQPP_EXPORT:
zmqpp_export.h

@bluca
Copy link
Member

bluca commented May 3, 2017

all classes use that macro, not sure what's happening with your IDE, I'm not a windows expert sorry, maybe someone else can help

@Smasherr
Copy link
Contributor Author

Smasherr commented May 3, 2017

The IDE only shows that zmqpp_EXPORTS is not currently defined in my environment. I realized this is irrelevant. zmqpp_EXPORTS should be set during compile time. I enabled the verbosity of makefile to check if that option is set during compilation of proxy.cpp. It was the case (see line 473). To my surprise adding ZMQPP_EXPORT to proxy class and repeated rebuilding of ZMQPP made my code link successfully this time.

So I'll send a PR, thanks for your support!

Smasherr added a commit to Smasherr/zmqpp that referenced this issue May 3, 2017
bluca added a commit that referenced this issue May 3, 2017
@bluca
Copy link
Member

bluca commented May 3, 2017

Fixed by #193

@bluca bluca closed this as completed May 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants