你的位置:首页 > 操作系统

[操作系统]解决更新到os x10.11后openssl头文件无法找到的问题


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即可以解决问题。