# Problem setting up C compiler on a Mac

This is a follow up to this question. I am using Mma 10 on a MacBook-Pro with OS-X Mavericks. After reading the documentation under CCompilerDriver/tutorial/SpecificCompilers I did the following:

Needs["CCompilerDriver"];
CCompilers[]


The documentations says they are the compilers that are found on my machine and that the CCompilerDriver package is automatically called when using CompilationTarget->"C" inside Compile. However, I can't get Compile working with CompilationTarget->"C". I also tried the Basic example in the documentation for CreateLibrary, and $Failed was returned. That means a suitable compiler could not be found. The documentation at CCompilerDriver/tutorial/SpecificCompilers also says, " Many Unix-type operating systems such as Linux or Mac OS X come with GCC already installed. If it is not present, then it can be added with a relatively simple configuration step." Can you help me with that simple configuration step? • What does FileNames["/usr/bin/clang"] give? It should give a result, since CCompilers[] is supposed to only list things that are actually installed. Aug 3, 2014 at 2:09 • Very likely you need to install Xcode. unless things changed with Mavericks, OSX has a compiler available but not installed by default. – user4860 Aug 3, 2014 at 3:28 ## 2 Answers To long for comment, Hit Command+Shift+G from the OS X desktop A Commandline will open, enter /user/bin and hit open There will open a new window, containing a long list, search for clang: If clang or others are NOT on this list, most likely you have to install "Command Line Tools" see here (or ask Google ...). Always check with friends when installing new Software! Good Luck! • After doing that I see the clang file. Then I wrote the simple Compile function acl suggested below. It compiled without problem and it works. The problem is solved! Aug 3, 2014 at 16:35 Very likely you need to install Xcode. Unless things changed with Mavericks, OSX has a compiler available but not installed by default As Brett Champion mentioned, try FileNames["/usr/bin/clang"] If this returns a file, then clang (A compiler) is installed, and likely should work. • FileNames["/usr/bin/clang"] returns {/usr/bin/clang}. I downloaded and installed Xcode, registered with Apple as an xCode developer. I can open the xCode IDE, but there may be some other steps needed to get it working. Anyway, I thought xCode is an objective-C compiler. From what I read it sounds like you can't write a C program for OSX. It seems you have to write an objective-C program instead. However, Compile in Mathematica doesn't allow for CompilationTarget->"objective C". So what do I do next? Aug 3, 2014 at 14:01 • @TedErsek You can most certainly write C programs for OSX (or any other language for which you have a compiler). XCode is an IDE, which is meant to help with writing code. It's focussed on objective C and C, but supports other languages. Now, you seem to have clang installed in the usual place, so there is some misconfiguration in mma itself. Does Compile[{{z, _Real, 1}}, Sin[z], CompilationTarget -> "C"] also return $Failed`?
– acl
Aug 3, 2014 at 15:28
• I evaluated that simple example. It compiles without problem, and it works. The problem is solved. Aug 3, 2014 at 16:37