clang - 将静态库与pch文件链接会导致__STATIC__禁用错误 [英] clang - linking a static library with a pch file causes error with __STATIC__ disabled

查看:2042
本文介绍了clang - 将静态库与pch文件链接会导致__STATIC__禁用错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正试图将一堆Objective C模块链接到一个静态库中。



我遇到以下错误,无法找到任何有关如何建立PCH档案时无法停用__STATIC__。

 错误:在PCH中禁用了__STATIC__预定义宏(与__DYNAMIC__相对)文件,但当前已启用

创建PCH文件的命令是:

  clang -cc1 -target-cpu x86-64 -g -fno-validate-pch -emit-pch -x objective-c-header afile.pch  - o afile.pch.bin -O0 -fmath-errno -fobjc-arc -fobjc-runtime = gnustep -fblocks -pthread -fexceptions -fobjc-exceptions -I ... 

有很多-I选项用于定位头文件。



库文件正在使用:

  clang -static -o lib.a -include-pch afile.pch.bin ... 



有几乎相同的链接选项和包含目录。



解决方案

当使用clang -cc1选项时,静态编译开关对于PCH头文件是:

  -static-define 

(主编译和链接应该使用--static而不是-static;这是从gcc文档而不是clang文档)


Am currently trying to link a bunch of Objective C modules into a static library.

I am getting the following error and am unable to locate any information on how the __STATIC__ can not be disabled when building a PCH file.

error: __STATIC__ predefined macro (as opposed to __DYNAMIC__) was disabled in PCH file but is currently enabled

The command to build the PCH file is:

clang -cc1 -target-cpu x86-64 -g -fno-validate-pch -emit-pch -x objective-c-header afile.pch -o afile.pch.bin -O0 -fmath-errno -fobjc-arc -fobjc-runtime=gnustep -fblocks -pthread -fexceptions -fobjc-exceptions -I...

With lots of -I options to locate header files.

The library file is being built with:

clang -static -o lib.a -include-pch afile.pch.bin ...

with pretty much the same link options and include directories.

Any help would be much appreciated on how to deal with this issue.

解决方案

When using the clang -cc1 option, the static compilation switch for the PCH header file is:

-static-define

(Also the main compilation and link should likely be using --static as opposed to -static; this is from the gcc documentation as opposed to the clang documentation)

这篇关于clang - 将静态库与pch文件链接会导致__STATIC__禁用错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆