MacOS – How to compile mod_wsgi, mod_fastcgi, etc on Mountain Lion (Mavericks) by fixing `apxs:Error: Command failed with rc=65536`

gccmacospythonxcode

I've updated to OS X Mountain Lion.
Update has removed all of my python and apache modules including mod_wsgi.

Now I'm trying to recompile mod_wsgi (it compiled without problems on Lion).

I use source code from here: http://code.google.com/p/modwsgi/wiki/DownloadTheSoftware?tm=2

./configure creates Makefile without problems:

$ ./configure
checking for apxs2... no
checking for apxs... /usr/sbin/apxs
checking Apache version... 2.2.22
checking for python... /usr/bin/python
configure: creating ./config.status
config.status: creating Makefile

But make returns error:

$ make
/usr/sbin/apxs -c -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -DENABLE_DTRACE -DMACOSX -DNDEBUG -DNDEBUG -DENABLE_DTRACE  -Wc,'-arch x86_64' mod_wsgi.c -Wl,-F/System/Library/Frameworks -framework Python -u _PyMac_Error /System/Library/Frameworks/  -arch x86_64 -ldl  -framework CoreFoundation  
/usr/share/apr-1/build-1/libtool --silent --mode=compile /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc    -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -I/usr/local/include -I/usr/include/apache2  -I/usr/include/apr-1   -I/usr/include/apr-1  -arch x86_64 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -DENABLE_DTRACE -DMACOSX -DNDEBUG -DNDEBUG -DENABLE_DTRACE  -c -o mod_wsgi.lo mod_wsgi.c && touch mod_wsgi.slo
env: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc: No such file or directory
apxs:Error: Command failed with rc=65536
.
make: *** [mod_wsgi.la] Error 1

Best Answer

I solved this problem while writting question:

For some reason /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/ folder (containing Xcode Command Line Tools) is here: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain

To fix the problem:

$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain

Greg Bair suggestion for Mavericks:

$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain

This creates symlink to the right folder.