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

Using mosquitto_log_printf in plugin yields undefined symbol on OSX #244

Closed
databus23 opened this issue Aug 11, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@databus23
Copy link
Contributor

commented Aug 11, 2016

I'm trying to build a simple auth plugin on OSX and I'm trying to use mosquitto_log_printf as advertised in <moquitto_plugin.h>.

While this works on Linux it yields this error on OSX:

> cc -Wall -fPIC -shared plugin.c -o plugin.so
Undefined symbols for architecture x86_64:
  "_mosquitto_log_printf", referenced from:
      _mosquitto_auth_plugin_init in plugin-ee448a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm using mosquitto installed via homebrew.

This can be reproduced using this empty skeleton:

#include <mosquitto.h>
#include <mosquitto_plugin.h>

int mosquitto_auth_plugin_version(void) {
  return MOSQ_AUTH_PLUGIN_VERSION;
}

int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count) {
  mosquitto_log_printf(MOSQ_LOG_INFO, "mosquitto_auth_plugin_init");
  return MOSQ_ERR_SUCCESS;
}

int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count) {
  return MOSQ_ERR_SUCCESS;
}

int mosquitto_auth_security_init(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count, bool reload) {
  return MOSQ_ERR_SUCCESS;
}

int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count, bool reload){

  return MOSQ_ERR_SUCCESS;
}

int mosquitto_auth_acl_check(void *user_data, const char *clientid, const char *username, const char *topic, int access) {
  return MOSQ_ERR_SUCCESS;
}

int mosquitto_auth_unpwd_check(void *user_data, const char *username, const char *password) {
  return MOSQ_ERR_SUCCESS;
}

int mosquitto_auth_psk_key_get(void *user_data, const char *hint, const char *identity, char *key, int max_key_len) {
  return 1; 
}

@databus23 databus23 changed the title Using mosquitto_log_printf in plugin causes undefined symbol on OSX Using mosquitto_log_printf in plugin yields undefined symbol on OSX Aug 11, 2016

@ralight

This comment has been minimized.

Copy link
Contributor

commented Aug 11, 2016

Thanks, I'll take a look later.

ralight added a commit that referenced this issue Aug 12, 2016

@ralight ralight added this to the Fixes-next milestone Aug 12, 2016

@ralight

This comment has been minimized.

Copy link
Contributor

commented Aug 12, 2016

The solution is to add -undefined dynamic_lookup to your command line when compiling. I've added a note in mosquitto_plugin.h.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.