当通过cmake编译mac的通用库时,包括i386和x86_64的不同头文件

时间:2014-05-11 22:48:03

标签: macos openssl cmake

我正在mac上构建一个通用库。我的库使用openssl函数和openssl库的链接。我可以分别为i386和x86_64编译openssl代码,然后创建一个胖库,使其成为i386和x86_64的通用库。

我的库是通过设置cmake通过CMAKE_OSX_ARCHITECTURES=i386;x86_64编译的,以便在i386和x86_64之间实现通用 为i386和x86_64生成的openssl标头不同。如何让cmake为i386和x86_64选择不同的标题?

2 个答案:

答案 0 :(得分:1)

AFAIK,当前的openssl构建过程不直接支持OS X通用构建。一种方法是单独编译每个体系结构,然后使用lipo -combine将每个库文件的两个变体组合成一个组合的通用文件。见man 1 lipo。这里有一个例子:https://gist.github.com/tmiz/1441111

答案 1 :(得分:0)

  

在为mac ...编译通用库时包含i386和x86_64的不同标题。

我不相信你可以为一个普遍或胖的图书馆做这件事。

在这种情况下,您需要不同的体系结构标头,您可能需要跳到框架,因为框架允许多组标头。但我认为我没有看到它用于架构独立。

Introduction to Framework Programming Guide讨论了Anatomy of Framework Bundles其他目录下的捆绑磁盘布局:

Directory     | Description
--------------+---------------------------------------------------------------------------------
Headers       | Contains any public headers you want to make available to external developers.
--------------+---------------------------------------------------------------------------------
Documentation | Contains HTML or PDF files describing the framework interfaces. Typically, 
              | documentation directories do not reside at the top level of your framework.
              | Instead, they reside inside your language-specific resource directories.
--------------+---------------------------------------------------------------------------------
Libraries     | Contains any secondary dynamic libraries your framework requires.