'How does gcc search framework headers on Mac OSX(10.15)?
By gcc -v I know that gcc searches in these paths:
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include
/usr/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
I write:
#include <CoreFoundation/CoreFoundation.h>
int main() {
return 0;
}
It gives no error messages. But with the following, gcc cannot find the header.
#include <CoreFoundation.framework/Headers/CoreFoundation.h>
int main() {
return 0;
}
I know that gcc finds the header CoreFoundation.h in /System/Library/Frameworks. And the path of the header is /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h.
My question is: why #include <CoreFoundation/CoreFoundation.h> is OK? Why not CoreFoundation.framework/Headers/CoreFoundation.h (it gives error messages)? I think it should be CoreFoundation.framework/Headers/CoreFoundation.h, as the full path of the header is /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h, and the inlcude path is /System/Library/Frameworks.
Thanks in advance.
The following may have something to do with this problem.
I compile a file that include 'CoreServices/CoreServices.h'.
did not find header 'CoreServices.h' in framework 'CoreServices' (loaded from '/System/Library/Frameworks')
Then I use gcc -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/, because I know the header's path is /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h. But it still doesn't work. Why?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
