I just upgraded to Mountain Lion OSX 10.8 and along with that I foolishly upgraded to Xcode 4.4.
However, after this upgrade "make" is gone and things like gcc -v also do not work.
This is a big thing since I am writing my phD and I rely on make to compile my LaTeX docs...
Downloading the "command line tools"
http://adcdownload.apple.com/Developer_Tools/xcode_4.4_gm_seed/cltools10_8gmseed6938077a.dmg
Is apparently not allowed for non-paying dev accounts.
What kind of foolishness is this?
They're not gone, they've just been relocated to inside Xcode's app bundle. This is actually nicer as it allows side by side installs of different XCode/SDK versions.
You can find them at: /Applications/Xcode.app/Contents/Developer/usr/bin
Also check out the xcode-select tool to allow you to choose the current active toolchain path.
I did the same thing as you this morning. To fix it, I just added the following to my ~/.bash_profile:
export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin
Interestingly,
The "Downloads" interface inside Xcode 4.4 seems to point to the following location for downloading the "Command line tools":
http://adcdownload.apple.com/Developer_Tools/xcode_4.4_gm_seed/cltools10_8gmseed6938077a.dmg
Judging by the "gm" reference in that URL I think this is an error. Without a paying dev account you cannot download this...
I issued the export PATH command, and then tried to compile hello.c, but compilation fails because it does not find the file stdio.h. So, I changed the include statement to specify the full path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/stdio.h, but then compilation fails because it does not find 3 other .h files.
export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin
cat hello.c
#include <stdio.h>
int main()
{
printf("Hello World \n");
}
gcc hello.c -o hello
hello.c:1:19: error: stdio.h: No such file or directory
hello.c: In function ‘main’:
hello.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
gcc hello.c -o hello
In file included from hello.c:2:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/stdio.h:64:23: error: sys/cdefs.h: No such file or directory
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/stdio.h:65:26: error: Availability.h: No such file or directory
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/stdio.h:67:20: error: _types.h: No such file or directory
Old thread, but I was just looking for this myself in Xcode 4.6:
Install Xcode
Go to Preferences->Downloads->Components and there will be an "Install" button next to "Command Line Tools"
Related
After upgrading macOS BigSur to 11.1 and Xcode to 12.3 this morning my MacPorts 2.6.4 distribution started to have problems. I can no longer compile a simple C++ program with the GNU C++ v10.2.0_4:
g++ -O3 -std=c++11 -c libvec.cpp
In file included from /opt/local/include/gcc10/c++/cmath:45,
from libvec.cpp:1:
/opt/local/lib/gcc10/gcc/x86_64-apple-darwin20/10.2.0/include-fixed/math.h:45:10: fatal error: sys/cdefs.h: No such file or directory
45 | #include <sys/cdefs.h>
| ^~~~~~~~~~~~~
compilation terminated.
Preliminary internet search suggests that this problem may be caused by the inconsistency with the Xcode command line tools. Would you please direct me, on how to debug and fix it? Maybe I need to reinstall the MacPorts distribution after such an upgrade? Thank you!
This issue is indeed caused by the macOS update from 11.0 to 11.1 and Xcode update from 12.2 to 12.3. Apple's new policy is to increment the SDK version with each system update. The MacPorts GNU C++ compiler installed with a previous SDK version fails now due to this increment. A quick workaround is to set the SDKROOT environment variable to match the new version number:
export SDKROOT=`xcrun --show-sdk-path`
Place this command into your ~/.profile file for convenience. Detailed issue explanation and this solution may be found in the following thread on MacPorts mailing list.
I am trying to compile a simple "hello world" program with gcc on macOS and for some reason I get the error
"fatal error: stdio.h: No such file or directory"
The interesting thing is that, if I compile using the entire path, so
/usr/bin/gcc hello.c
then everything works out fine. Although, if I run
which gcc
I get
/usr/local/bin/gcc
and with this path the compilation gives me the same error.
I used homebrew to install gcc, Xcode is up do date.
I really need to get this work, because I need to compile a code that uses both fortran and c modules, nd I have no idea how to modify the Makefile. Fortran compilation with gfortran works out fine.
Thanks!
Follow steps
Step 1 : run xcode-select --install
Step2 : Added this line
export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
to your .bash_profile file.
Step 3 : restart the terminal.
The issue I'm having is that gcc (and family) don't appear to be properly setup. I have a 10.7.4 machine that I just installed Xcode on (from the app store). I've done no prior development on this machine.
Working w/in Xcode seems to work fine. I can build and compile no problem. However, trying to execute gcc command line fails.
First, I gcc wasn't on my path ... no big deal. I located it and ran as:
/Applications/Xcode.app/Contents/Developer/usr/bin/gcc -dynamiclib -fno-common -o s.dylib s.c
(I'm working on a lib w/some functions...). Anyways, it fails.
s.c:1:19: error: stdio.h: No such file or directory
s.c:2:20: error: stdlib.h: No such file or directory
s.c:3:20: error: string.h: No such file or directory
Surprise! hah, well I searched my machine for stdio.h and I can't find it anywhere. Since I've been out of the OSX game for a bit, I'm assuming I'm missing something -
Basically I want to be able to continue using Xcode but I want to be able to build C/C++/etc on the command line with all the dependencies (.h) in the correct place.
Any thoughts?
There are two main ways to run the compiler from the command line: the Command Line Tools package, and xcrun.
xcrun is particularly good if you just need this occasionally. Just stick "xcrun" at the start, like you'd do with sudo:
xcrun gcc -dynamiclib -fno-common -o s.dylib s.c
This will find the correct version of gcc and set the needed directories, etc. You can specify a specific SDK with --sdk.
If you do this a lot, download and install the Command Line Tools package (Xcode>Open Developer Tool>More Tools...; it also may be available in Preferences>Downloads). This installs a full copy of everything in /usr.
Probably xcrun is not enough if you are using 10.8.
Looking in to the clang documentation I found that you need to include the system root because you do not have your libraries in the standard place but inside Xcode.
using:
xcrun gcc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
or:
xcrun clang -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
I'm trying to compile pulseaudio on Mac OS X, however by default I get lots of errors about not finding standard files like inttypes.h, errno.h or stdio.h. Putting -isystem/usr/include in CPPFLAGS fixes those errors, but then later on I get fatal error: 'CoreServices/CoreServices.h' file not found.
I've tried also adding -framework CoreServices and/or
-I/System/Library/Frameworks/CoreServices.framework/Headers but neither work.
What's the proper way of making the compiler find it?
I think I'm using clang, gcc produces even more errors.
You are on the right track, those are the framework and include flags but if you use the correct configuration options you will find even the system includes are picked up properly.
The Makefiles will attempt to set the framework appropriately based on the --with-mac-sysroot and --with-mac-version-min attributes.
Example configuration option to specify the SDK location:
--with-mac-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/
--with-mac-version-min=10.7
If you are building on Mountain lion (10.8) you still need to use the 10.7 minimum compatibility as there are headers missing in the 10.8 SDK which PulseAudio makes reference to.
You can pass the configure options to the autogen.sh which will run configure once autoconf has completed. You can try the following command which has been tested on the master branch:
./autogen.sh --prefix=/usr/local --disable-jack --disable-hal --disable-bluez --disable-avahi --with-mac-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/ --with-mac-version-min=10.7 --disable-dbus
If you get m4 macro errors copy the m4 macros from aclocal into the m4 sub-directory and try again.
There are a few other problems but these are bound to be cleared up may date quickly. Adding it here as it may help someone trying to get this built.
error: Multiprocessing.h cannot be found:
This has been deprecated in 10.7 but the headers are still included it CoreServices and will build just change the include instruction in the file src/pulsecore/semaphore-osx.c.
-#include <Multiprocessing.h>
+#include <CoreServices/CoreServices.h>
error: ‘lt_PROGRAM_LTX_preloaded_symbols’ undeclared.
This may be a problem compiling src/daemon/dumpmodules.c and can be fixed by declaring the external macro.
extern const lt_dlsymlist lt_preloaded_symbols[];
error: gdbm.h: No such file or directory
For some reason the default include dir is not considered by the compiler and you can add the path to the src/Makefile look for and set the variable GDBM_CFLAGS.
GDBM_CFLAGS=-I/usr/local/include
nJoy!
I am getting started with using MEX files for MATLAB (R2012a) compiled from C code (using XCode 4.3) on my Mac (running OSX 10.7.3, Lion). I have already installed the MATLAB provided XCode patch which configures MATLAB to use the new llvm-gcc compiler under XCode 4.2+, but I am still getting the following error attempting to compile the example file using mex timestwo.c:
/Applications/MATLAB_R2012a.app/extern/include/matrix.h:852:20: error: stdlib.h: No such file or directory
In file included from timestwo.c:1:
/Applications/MATLAB_R2012a.app/extern/include/mex.h:161:19: error: stdio.h: No such file or directory
The compilation then breaks
mex: compile of ' "timestwo.c"' failed.
Error using mex (line 206)
Unable to complete successfully.
Clearly, the compiler can't find the standard library header directory, but what do I need to change to successfully compile?
Ah, found it!
The MATLAB provided template uses /Developer/... for the SDK location, but this changed under XCode4.3 to live under the XCode.app. To fix things, I had to edit my ~/.matlab/R2012a/mexopts.sh file to set the SDKROOT directory to the new location.
To do this, search for SDKROOT in the mexopts.sh file and change it to read:
SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/'
Note, I chose the 10.7 sdk b/c I am on Lion. Use 10.6 if you are on Snow Leopard
I am running Mac Mountain Lion and Matlab R2012b, and the following solution worked for me: Matlab 2012a Mex to work with Xcode 4.5 on Mountain Lion
To be precise,
I was getting the following errors:
error: stdio.h: No such file or directory
error: stdlib.h: No such file or directory
error: math.h: No such file or directory
So what I did to solve this issue:
I installed Xcode with Command Line Tools, and then edited the file "/Applications/MATLAB_R2012b.app/bin/mexopts.sh" by:
changing CC from gcc-4.2 to llvm-gcc-4.2
changing CXX from gcc-4.2 to llvm-g++-4.2
setting SDKROOT to '/'
Then I ran "mex -setup" in MATLAB, chose number 1, and chose y to overwrite the old /Users/insertyournamehere/.matlab/R2012b/mexopts.sh
That solved it :)
You will find valuable information here: http://www.mathworks.fr/support/solutions/en/data/1-FR6LXJ/