clang - linking a static library with a pch file causes error with __STATIC__ disabled

狂风中的少年 提交于 2019-12-25 04:15:59

问题


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.


回答1:


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)



来源:https://stackoverflow.com/questions/30521176/clang-linking-a-static-library-with-a-pch-file-causes-error-with-static-di

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!