MacOS下配置MySQL Connector C++时CMake提示SSL库未找到的问题求助
Got it, let's tackle this SSL library issue you're facing during the CMake configuration step. Here's what you need to do:
Step 1: Install OpenSSL via Homebrew
macOS ships with LibreSSL by default, but MySQL Connector C++ often works better with the official OpenSSL distribution. If you don't have Homebrew installed, grab it first (since you're building from source, I assume you already have it set up).
Run this command to install OpenSSL:
brew install openssl
Step 2: Get the OpenSSL Installation Path
Homebrew installs OpenSSL to a versioned directory. To find the exact path, run:
brew --prefix openssl
This will output something like /usr/local/opt/openssl@3 (for OpenSSL 3.x) or /usr/local/opt/openssl@1.1 (for older supported versions).
Step 3: Update Your CMake Command with WITH_SSL
Modify your original CMake command to include the WITH_SSL flag pointing to the path you just retrieved. For example, if your path is /usr/local/opt/openssl@3, run:
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/connector-c++-8.0 -DWITH_SSL=/usr/local/opt/openssl@3
Alternatively, you can try using the shorthand brew value for WITH_SSL (this tells CMake to auto-detect the Homebrew-installed OpenSSL):
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/connector-c++-8.0 -DWITH_SSL=brew
Why This Works
The error pops up because the build script can't reliably recognize macOS's default LibreSSL as a compatible SSL library. By specifying the Homebrew-installed OpenSSL path, you're pointing CMake to a version that MySQL Connector C++ explicitly supports (OpenSSL 1.1.1 or newer).
内容的提问来源于stack exchange,提问作者Bamaco

