Search code examples
gcccygwinmqttmosquitto

Mosquitto with Cygwin


I want to run Mosquitto on Windows using Cygwin and I have installed Cygwin and downloaded Mosquitto as they describe on Mosquitto's site.

I have a simple example-file taken from mosquitto's site.

When I compile with this gcc-line:

gcc -Wall -o test test.c -I /home/Mathias/mosquitto-1.1.3/lib/ -L/home/Mathias/mosquitto-1.1.3/lib/ -lmosquitto

I get this error output:

/home/Mathias/mosquitto-1.1.3/lib//libmosquitto.a(mosquitto.o): In function     `_mosquitto_destroy':
/home/Mathias/mosquitto-1.1.3/lib/mosquitto.c:285: undefined reference to `_SSL_free'
/home/Mathias/mosquitto-1.1.3/lib/mosquitto.c:288: undefined reference to `_SSL_CTX_free'
/home/Mathias/mosquitto-1.1.3/lib//libmosquitto.a(net_mosq.o): In function `psk_client_callback':
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:201: undefined reference to `_SSL_get_ex_data'
/home/Mathias/mosquitto-1.1.3/lib//libmosquitto.a(net_mosq.o): In function `_mosquitto_net_init':
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:94: undefined reference to `_SSL_load_error_strings'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:95: undefined reference to `_SSL_library_init'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:96: undefined reference to `_OPENSSL_add_all_algorithms_noconf'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:98: undefined reference to `_SSL_get_ex_new_index'
/home/Mathias/mosquitto-1.1.3/lib//libmosquitto.a(net_mosq.o): In function `_mosquitto_net_cleanup':
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:106: undefined reference to `_ERR_free_strings'
/home/Mathias/mosquitto-1.1.3/lib//libmosquitto.a(net_mosq.o): In function `_mosquitto_socket_close':
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:175: undefined reference to `_SSL_shutdown'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:176: undefined reference to `_SSL_free'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:180: undefined reference to `_SSL_CTX_free'
/home/Mathias/mosquitto-1.1.3/lib//libmosquitto.a(net_mosq.o): In function `_mosquitto_socket_connect':
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:274: undefined reference to `_SSL_shutdown'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:275: undefined reference to `_SSL_free'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:279: undefined reference to `_SSL_CTX_free'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:308: undefined reference to `_TLSv1_client_method'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:308: undefined reference to `_SSL_CTX_new'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:321: undefined reference to `_SSL_CTX_ctrl'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:325: undefined reference to `_SSL_CTX_ctrl'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:329: undefined reference to `_SSL_CTX_set_cipher_list'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:337: undefined reference to `_SSL_CTX_load_verify_locations'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:360: undefined reference to `_SSL_CTX_set_verify'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:366: undefined reference to `_SSL_CTX_set_default_passwd_cb'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:367: undefined reference to `_SSL_CTX_set_default_passwd_cb_userdata'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:371: undefined reference to `_SSL_CTX_use_certificate_file'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:402: undefined reference to `_SSL_CTX_set_psk_client_callback'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:406: undefined reference to `_SSL_new'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:411: undefined reference to `_SSL_set_ex_data'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:412: undefined reference to `_BIO_new_socket'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:417: undefined reference to `_SSL_set_bio'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:419: undefined reference to `_SSL_connect'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:421: undefined reference to `_SSL_get_error'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:362: undefined reference to `_SSL_CTX_set_verify'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:383: undefined reference to `_SSL_CTX_use_PrivateKey_file'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:393: undefined reference to `_SSL_CTX_check_private_key'
/home/Mathias/mosquitto-1.1.3/lib//libmosquitto.a(net_mosq.o): In function `_mosquitto_net_read':
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:543: undefined reference to `_SSL_read'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:545: undefined reference to `_SSL_get_error'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:555: undefined reference to `_ERR_get_error'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:557: undefined reference to `_ERR_error_string'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:558: undefined reference to `_ERR_get_error'
/home/Mathias/mosquitto-1.1.3/lib//libmosquitto.a(net_mosq.o): In function `_mosquitto_net_write':
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:593: undefined reference to `_SSL_write'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:595: undefined reference to `_SSL_get_error'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:605: undefined reference to `_ERR_get_error'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:607: undefined reference to `_ERR_error_string'
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:608: undefined reference to `_ERR_get_error'
/home/Mathias/mosquitto-1.1.3/lib//libmosquitto.a(net_mosq.o): In function `_mosquitto_net_cleanup':
/home/Mathias/mosquitto-1.1.3/lib/net_mosq.c:107: undefined reference to `_EVP_cleanup'
/home/Mathias/mosquitto-1.1.3/lib//libmosquitto.a(util_mosq.o): In function `_mosquitto_hex2bin':
/home/Mathias/mosquitto-1.1.3/lib/util_mosq.c:309: undefined reference to `_BN_hex2bn'
/home/Mathias/mosquitto-1.1.3/lib/util_mosq.c:319: undefined reference to `_BN_free'
/home/Mathias/mosquitto-1.1.3/lib/util_mosq.c:313: undefined reference to `_BN_num_bits'
/home/Mathias/mosquitto-1.1.3/lib/util_mosq.c:318: undefined reference to `_BN_bn2bin'
/home/Mathias/mosquitto-1.1.3/lib/util_mosq.c:314: undefined reference to `_BN_free'
collect2: ld returned 1 exit status

I dont know how top go from here...

Appreciate any kind of help!


Solution

  • I solved the SSL errors by adding -lsslto the gcc line.

    Final gcc line:

    $ gcc -Wall -Imosquitto-1.1.3/lib/ -Lmosquitto-1.1.3/lib/ -lssl -lmosquitto -o test test.c mosquitto-1.1.3/lib/libmosquitto.so.1
    

    When solved this, another problem occured when running the application, which I have asked another question about: https://stackoverflow.com/questions/16517320/running-mosquitto-on-windows-using-cygwin