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 error for Windows DLL for static class variables in Channel.hpp #312

Open
CayOest opened this issue Oct 17, 2022 · 1 comment
Open

Comments

@CayOest
Copy link

CayOest commented Oct 17, 2022

Hi, when linking against the dynamic Windows DLL of SimpleAmqpClient, the following error occurs:

error LNK2001: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const AmqpClient::Channel::EXCHANGE_TYPE_DIRECT" (?EXCHANGE_TYPE_DIRECT@Channel@AmqpClient@@2V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@B)
3>C:\dev\cpp\x64\Debug\example-service.exe : fatal error LNK1120: 1 unresolved externals

This happens because the static variable EXCHANGE_TYPE_DIRECT is not exported.

See https://stackoverflow.com/questions/2479784/exporting-static-data-in-a-dll .

Hence, there should be some some getters/setters to set the three static variables in class Channel:
static const std::string
EXCHANGE_TYPE_DIRECT; ///< "direct" string constant
static const std::string
EXCHANGE_TYPE_FANOUT; ///< "fanout" string constant
static const std::string EXCHANGE_TYPE_TOPIC; ///< "topic" string constant

Or some other solution.

@CayOest
Copy link
Author

CayOest commented Oct 17, 2022

Since it seems to be used in Channel::DeclareExchange only, the simplest solution would be to directly set the default argument of the function as
void DeclareExchange( const std::string &exchange_name, const std::string &exchange_type = "direct", bool passive = false, bool durable = false, bool auto_delete = false);

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

1 participant