在 OSX 上构建 mariadb-connector-c

Building mariadb-connector-c on OSX

我正在尝试在最新的 OSX 上构建 C connector for MariaDB,但它似乎因与 SSL 相关的错误而失败。我使用 Macports (/opt/local/lib/openssl) 安装了 SSL,并添加了一个指向它的包含:

find_package(OpenSSL REQUIRED)
target_include_directories(tests PRIVATE ${OPENSSL_INCLUDE_DIR})

但是构建它returns同样的错误:

~/chi/databaseclient/cpp/ninja/mariadb-connector-c-src
⟩ ninja
[81/115] Building C object libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/inflate.c.o
zlib/inflate.c:1475:61: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
    if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
                                                        ~~~ ^
1 warning generated.
[89/115] Linking C shared library libmariadb/libmariadb.3.dylib
FAILED: libmariadb/libmariadb.3.dylib 
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -O2 -g -DNDEBUG -DDBUG_OFF -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -dynamiclib -Wl,-headerpad_max_install_names -compatibility_version 3.0.0 -current_version 3.0.0 -o libmariadb/libmariadb.3.dylib -install_name /Users/ruihpacheco/chi/databaseclient/cpp/ninja/mariadb-connector-c-src/libmariadb/libmariadb.3.dylib libmariadb/CMakeFiles/mariadb_obj.dir/__/plugins/auth/my_auth.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/plugins/auth/old_password.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/plugins/pvio/pvio_socket.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_array.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_charset.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_hash.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_net.c.o libmariadb/CMakeFiles/mariadb_obj.dir/mariadb_charset.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_time.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_default.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_errmsg.c.o libmariadb/CMakeFiles/mariadb_obj.dir/mariadb_lib.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_list.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_pvio.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_tls.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_alloc.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_compress.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_init.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_password.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_ll2str.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_sha1.c.o libmariadb/CMakeFiles/mariadb_obj.dir/mariadb_stmt.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_loaddata.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_stmt_codec.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_string.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_dtoa.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_client_plugin.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_io.c.o libmariadb/CMakeFiles/mariadb_obj.dir/secure/openssl.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/adler32.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/compress.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/crc32.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/deflate.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/gzclose.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/gzlib.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/gzread.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/gzwrite.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/infback.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/inffast.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/inflate.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/inftrees.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/trees.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/uncompr.c.o libmariadb/CMakeFiles/mariadb_obj.dir/__/zlib/zutil.c.o libmariadb/CMakeFiles/mariadb_obj.dir/mariadb_dyncol.c.o libmariadb/CMakeFiles/mariadb_obj.dir/mariadb_async.c.o libmariadb/CMakeFiles/mariadb_obj.dir/ma_context.c.o  /usr/lib/libiconv.dylib /usr/lib/libssl.dylib /usr/lib/libcrypto.dylib && :
Undefined symbols for architecture x86_64:
  "_X509_check_host", referenced from:
      _ma_tls_verify_server_cert in openssl.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)
[91/115] Building C object unittest/libmariadb/CMakeFiles/ps_bugs.dir/ps_bugs.c.o
ninja: build stopped: subcommand failed.

MariaDB Connector/C 可与所有受支持的 OpenSSL 版本一起正常工作。

错误 'Undefined symbols for architecture x86_64 "_X509_check_host"' 表示您使用的是不再受支持的旧 OpenSSL 版本。 X509_check_host 是在 OpenSSL 1.0.2 中引入的。

请将您的 OpenSSL 版本更新到 1.0.2 或更高版本。另见 https://www.openssl.org/policies/releasestrat.html

出于某种原因,基本上 CMake 使用 Macports 头文件而不是系统库。