~/Documents/github/mosquitto (master ✔) ᐅ cmake .
-- The C compiler identification is AppleClang 9.0.0.9000039
-- The CXX compiler identification is AppleClang 9.0.0.9000039
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenSSL: /usr/lib/libcrypto.dylib (found version "1.0.2n")
-- Looking for getaddrinfo_a in anl
-- Looking for getaddrinfo_a in anl - not found
-- Configuring done
CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
MACOSX_RPATH is not specified for the following targets:
libmosquitto
mosquittopp
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done
-- Build files have been written to: /Users/chipengliu/Documents/github/mosquitto
~/Documents/github/mosquitto (master ✘)✹✭ ᐅ make
Scanning dependencies of target libmosquitto
[ 1%] Building C object lib/CMakeFiles/libmosquitto.dir/logging_mosq.c.o
[ 3%] Building C object lib/CMakeFiles/libmosquitto.dir/memory_mosq.c.o
[ 5%] Building C object lib/CMakeFiles/libmosquitto.dir/messages_mosq.c.o
[ 7%] Building C object lib/CMakeFiles/libmosquitto.dir/mosquitto.c.o
[ 8%] Building C object lib/CMakeFiles/libmosquitto.dir/net_mosq.c.o
[ 10%] Building C object lib/CMakeFiles/libmosquitto.dir/read_handle.c.o
[ 12%] Building C object lib/CMakeFiles/libmosquitto.dir/read_handle_client.c.o
[ 14%] Building C object lib/CMakeFiles/libmosquitto.dir/read_handle_shared.c.o
[ 16%] Building C object lib/CMakeFiles/libmosquitto.dir/send_client_mosq.c.o
[ 17%] Building C object lib/CMakeFiles/libmosquitto.dir/send_mosq.c.o
[ 19%] Building C object lib/CMakeFiles/libmosquitto.dir/socks_mosq.c.o
[ 21%] Building C object lib/CMakeFiles/libmosquitto.dir/srv_mosq.c.o
[ 23%] Building C object lib/CMakeFiles/libmosquitto.dir/thread_mosq.c.o
[ 25%] Building C object lib/CMakeFiles/libmosquitto.dir/time_mosq.c.o
[ 26%] Building C object lib/CMakeFiles/libmosquitto.dir/tls_mosq.c.o
[ 28%] Building C object lib/CMakeFiles/libmosquitto.dir/util_mosq.c.o
[ 30%] Building C object lib/CMakeFiles/libmosquitto.dir/will_mosq.c.o
[ 32%] Linking C shared library libmosquitto.dylib
Undefined symbols for architecture x86_64:
"_SSL_CTX_set_psk_client_callback", referenced from:
__mosquitto_socket_connect_step3 in net_mosq.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libmosquitto.1.4.14.dylib] Error 1
make[1]: *** [lib/CMakeFiles/libmosquitto.dir/all] Error 2
make: *** [all] Error 2
How to solve these problems when I build mosquitto on macOS ?
Please read the https://github.com/eclipse/mosquitto#build-dependencies section. The cmake files are not smart enough to tell you directly about missing dependencies.
It doesn't look like the version of openssl you have has TLS PSK support. You could try to get something more modern, or disable TLS PSK support: cmake -DWITH_TLS_PSK=no should do it, but I haven't tested. Alternatively, I'd suggest you get it through homebrew.
@ralight I have installed openssl through homebrew , but I still haven't found out what the problem is.
openssl version
OpenSSL 1.0.2n 7 Dec 2017
In that case you need to find out the path to the homebrew installed openssl files and pass that as an argument to cmake so it can detect it. Something like:
cmake -DOPENSSL_INCLUDE_DIR=/usr/local/Cellar/openssl/1.0.2n/include -DOPENSSL_CRYPTO_LIBRARY=/usr/local/Cellar/openssl/1.0.2n/lib/libcrypto.dylib -DOPENSSL_SSL_LIBRARY=/usr/local/Cellar/openssl/1.0.2n/lib/libssl.dylib .
This appears to be solved based on the :+1: , so I'm going to close it.
Most helpful comment
In that case you need to find out the path to the homebrew installed openssl files and pass that as an argument to cmake so it can detect it. Something like:
cmake -DOPENSSL_INCLUDE_DIR=/usr/local/Cellar/openssl/1.0.2n/include -DOPENSSL_CRYPTO_LIBRARY=/usr/local/Cellar/openssl/1.0.2n/lib/libcrypto.dylib -DOPENSSL_SSL_LIBRARY=/usr/local/Cellar/openssl/1.0.2n/lib/libssl.dylib .