os x從10.10更新到10.11后,原有代碼編譯報錯,#include <openssl/ssl.h>等頭文件無法找到: "openssl/ssl.h: No such file or directory".
原有環境:os x10.10+Xcode6
更新后的環境:os x10.11+Xcode7, Qt5.3.1+Qt Creator 3.3.0
解決辦法:
1.命令行執行:xcode-select —install,安裝xcode命令行工具,/usr路徑下出現include目錄 (如果原來/usr/include目錄已經存在,跳過這一步);
/usr/include/openssl目錄里包含了相關的頭文件
2.在/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/路徑下創建openssl目錄;
3.把 /usr/include/openssl路徑下的所有文件拷貝到剛建立的openssl目錄下;
原因:
os x10.11開始,蘋果sdk中不再提供openssl,在Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include路徑下是找不到原有的openssl目錄的。
"
Sadly, it looks like we're not supposed to use it any more. As you say, it's included in the 10.10 SDK, but is deliberately missing from the 10.11 SDK.
http://lists.apple.com/archives/macnetworkprog/2015/Jun/msg00025.html
"
參考:
1.https://forums.developer.apple.com/thread/3897
2.http://stackoverflow.com/questions/14655154/mac-os-x-lion-does-not-have-usr-include-folder
另外升級后,Qt Creator中編譯會報找不到<sys/time.h>等系統頭文件,修改~/Qt5.3.1/5.3/clang_64/mkspecs/qdevice.pri文件,把macsox10.10改為macosx10.11即可以解決問題。