2
$\begingroup$

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[]

enter image description here

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?

$\endgroup$
2
  • $\begingroup$ What does FileNames["/usr/bin/clang"] give? It should give a result, since CCompilers[] is supposed to only list things that are actually installed. $\endgroup$ Aug 3, 2014 at 2:09
  • $\begingroup$ Very likely you need to install Xcode. unless things changed with Mavericks, OSX has a compiler available but not installed by default. $\endgroup$
    – user4860
    Aug 3, 2014 at 3:28

2 Answers 2

1
$\begingroup$

To long for comment,

Hit Command+Shift+G from the OS X desktop

A Commandline will open,

enter /user/bin and hit open

enter image description here

There will open a new window, containing a long list, search for clang:

enter image description here

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!

$\endgroup$
1
  • $\begingroup$ 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! $\endgroup$
    – Ted Ersek
    Aug 3, 2014 at 16:35
2
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$
    – Ted Ersek
    Aug 3, 2014 at 14:01
  • $\begingroup$ @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? $\endgroup$
    – acl
    Aug 3, 2014 at 15:28
  • $\begingroup$ I evaluated that simple example. It compiles without problem, and it works. The problem is solved. $\endgroup$
    – Ted Ersek
    Aug 3, 2014 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.