eclipse / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
8.93k stars 2.37k forks source link

XCode 12 Compile Errors and Fixes #1873

Open ghost opened 3 years ago

ghost commented 3 years ago

When I tried the fixes branch to compile to fix https://github.com/eclipse/mosquitto/issues/1831 , got same sort of error as https://github.com/eclipse/mosquitto/issues/1831 only in a different file.

[ 65%] Building C object src/CMakeFiles/mosquitto.dir/logging.c.o
/Users/tristan/Coding/mosquitto/src/logging.c:97:2: error: implicit declaration of function 'gettimeofday' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
        gettimeofday(&tv, NULL);
        ^

I had to add

#include <sys/time.h>

to the logging.c file

(update see comment below... me forgot params) Also, it seems that it does not link the crypto correctly although cmake output is correct it links it to the apple one when using brew...

Running: cmake --DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/lib -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include .

-- Found OpenSSL: /usr/local/opt/openssl/lib/libcrypto.dylib (found version "1.1.1h")

But when compiling...

[ 33%] Linking C shared library libmosquitto.dylib
ld: cannot link directly with dylib/framework, your binary is not an allowed client of /usr/lib/libcrypto.dylib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libmosquitto.1.6.12.dylib] Error 1

Fix for that was here... https://gist.github.com/llbbl/c54f44d028d014514d5d837f64e60bac by changing the version number from 1.1.1d to 1.1.1h

Reference https://stackoverflow.com/questions/58446253/xcode-11-ld-error-your-binary-is-not-an-allowed-client-of-usr-lib-libcrypto-dy


A very happy compilation... without error on [33%] and [66%] :-)

[ 85%] Linking C executable mosquitto
[100%] Built target mosquitto
ghost commented 3 years ago

the second was my mistake... did not know about

-DOPENSSL_SSL_LIBRARY=/usr/local/opt/openssl@1.1/lib/libssl.dylib 
-DOPENSSL_CRYPTO_LIBRARY=/usr/local/opt/openssl@1.1/lib/libcrypto.dylib