You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

从源码构建Qt时如何指定macOS最低SDK版本?

Fixing MACOSX_DEPLOYMENT_TARGET Mismatch When Building Qt from Source

I’ve hit this exact snag before—let’s break down what’s going wrong and how to fix it:

The Root Issue

Qt’s ./configure script reads the MACOSX_DEPLOYMENT_TARGET environment variable the moment you run it, and uses that value to generate all the build configuration files (like Makefiles). If you set the variable after running configure, those files already have the default (or previously detected) OS version baked in—your later export command won’t retroactively change anything.

Correct Build Workflow

To get the minimum SDK version set properly to 10.9, follow these steps in order:

  1. Clean up any prior build traces (if you’ve already run configure or make):
    make distclean
    
  2. Set the deployment target before running configure:
    export MACOSX_DEPLOYMENT_TARGET="10.9"
    
  3. Run configure (you can optionally add the -sdk flag to explicitly point to the 10.9 SDK for extra certainty, if you have it installed in Xcode):
    ./configure -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk [your other configure flags]
    
  4. Start the build:
    make -j$(sysctl -n hw.ncpu)
    

Verify the Fix

Once the build finishes, re-run your otool check to confirm the version matches your expectation:

otool -l lib/QtCore.framework/QtCore | grep LC_VERSION_MIN_MACOSX -A 5

You should now see version 10.9 in the output instead of 10.10.

Quick Extra Tips

  • If you skip the -sdk flag, Qt will use the latest SDK available in your Xcode installation, but still honor the MACOSX_DEPLOYMENT_TARGET for the minimum supported OS.
  • For Qt 5.x and newer, you can also use the QMAKE_MACOSX_DEPLOYMENT_TARGET variable in project files, but setting the system environment variable before configure is the most reliable way to enforce it across the entire Qt build.

内容的提问来源于stack exchange,提问作者Ad N

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:51:21