我想使用Cygwin在Windows上运行Mosquitto,我已经安装了Cygwin,并按照他们在Mosquitto网站上的描述下载了Mosquitto。
我有一个简单的示例文件来自mosquitto的网站。
当我用这个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
我收到此错误输出:
/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
我不知道如何从这里开始......
感谢任何帮助!
答案 0 :(得分:0)
鉴于错误消息与SSL相关,看起来SSL没有安装在cygwin中。
setup.exe
并回答提示以返回Select Packages
屏幕。Libs
部分,然后选择所需的库。或者,您可以从openssl
部分安装整个Net
包,并让cygwin安装所有必需的依赖项。
答案 1 :(得分:0)
我通过将-lssl
添加到gcc行来解决了SSL错误。
最终gcc专栏:
$ 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
解决这个问题后,运行应用程序时出现了另一个问题,我提出了另一个问题:https://stackoverflow.com/questions/16517320/running-mosquitto-on-windows-using-cygwin