Message Boards Message Boards

0
|
3243 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Choose your clang compiler on OS X ( use Macports)

Posted 8 years ago

In Mathematica's LibraryLink package and CCompilerDriver package, you have the option to choose a specific compiler. This would enable you to use future release of gcc/intel/llvm for test or the legacy version for compatibility. Here is an quick example:

On my OS X 10.11.2, I have a default clang at /usr/local/bin and several other compilers from Macports.

clangs

To use any of them in Mathematica, I can load this package first:

Needs["CCompilerDriver`"]

The default setting of the compiler list is

CCompilers[Full] // TableForm

complier_list

I can set the global keyword $CCompiler with the following value:

$CCompiler = {"Name" -> "Clang", 
  "Compiler" -> CCompilerDriver`ClangCompiler`ClangCompiler, 
  "CompilerInstallation" -> "/opt/local/bin/clang-mp-3.6", 
  "CompilerName" -> Automatic}; 

I use this simple example from the documentation of CreateExecutable plus "ShellCommandFunction" -> Print so that I can see the cascaded build command. Use the Import["!"] to pass result back to front end with unix pipe:

buildres

POSTED BY: Shenghui Yang
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract