I know that Mac OS X is a Unix-based system. And I heard that C standard library such as stdio.h, is located in /usr/local/include
or /usr/include
. But there is not any kind of library in this directory. I use Terminal to search this directory and I also use command like find ./ -iname "stdio.h"
, but nothing comes out. However, strangely enough, gcc -test.c -o test
command works out. How did it happen? I want to know where my C library is located. p.s I also use Xcode, too. Is it related with this application? help me! And I have AWS EC2 linux server, and it has both libraries that i refereed above.
From there, usr/include holds common public headers such as the standard C headers, and various Apple headers are in frameworks under System . In /Applications/Xcode. app/Contents/Developer/Platforms , you will likely find folders for other platforms, such as iPhoneOS. platform and AppleTVOS.
Assuming C h> is one of the standard C headers. Your compiler complains that it can not find this header. This means that your standard library is broken. Consider reinstalling your compiler.
h> You tell the compiler to search for the file 'stdio. h' in the standard library folders only . but when you write #include”stdio. h” You mean that search the file 'stdio. h' in the standard library functions as well as in the current folder where you are working .
The library is in whichever one of the C Runtime Libraries against which you are linking. Those libraries are in the VC\lib folder in the Visual Studio installation directory. Thanks for your answer.
If you have Xcode but have not installed the optional Command Line Tools package then the standard includes and libraries may not be found in the usual place. Try:
$ find /Applications/Xcode.app -name stdio.h
and you'll probably see something like:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/tr1/stdio.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdio.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/sys/stdio.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/tr1/stdio.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/stdio.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sys/stdio.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/stdio.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/tr1/stdio.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/stdio.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/stdio.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/tr1/stdio.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/stdio.h
However you might want to install the Command Line Tools package if you plan on doing any non-Xcode (i.e. command line) programming. You will then see the usual headers and libraries in /usr/include
and /usr/lib
.
If you don't have Command Line Tools installed you can run:
xcode-select --install
A dialogue box opens for you to accept the license agreement and so on.
(This was missing from the above responses.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With