-
Notifications
You must be signed in to change notification settings - Fork 11
Prerequisites for C Compiler
MathCompile depends on a C++ compiler that supports C++17 standard to compile Wolfram Language functions to machine code.
The C++ compiler is platform dependent.
- On Unix-like systems, compatible GCC or Clang may have been installed already and Mathmatica should be able to find it automatically, but the default settings can be overridden by
CCompilerDriver`$CCompiler
following the instructions below. - On Windows, you need to install GCC through MinGW-w64 or install Microsoft Visual C++ compiler, if you do not have either of them.
To make the configurations on $CCompiler
permanent, you can add the command to the initialization file $BaseDirectory/Kernel/init.m
.
To manually switch to GCC,
CCompilerDriver`$CCompiler = CCompilerDriver`GCCCompiler`GCCCompiler;
To enable Clang on Linux, set $CCompiler
with the installation path and specify the compiler name, e.g.
CCompilerDriver`$CCompiler = {
"Compiler" -> CCompilerDriver`GenericCCompiler`GenericCCompiler,
"CompilerInstallation" -> "/usr/bin",
"CompilerName" -> "clang++"
};
Apple Clang is the default compiler on macOS. It will be detected automatically without configuring $CCompiler
.
Intel C++ compiler is freely available to students and open source contributors, Intel Parallel Studio XE.
To enable Intel C++, set $CCompiler
with the installation path, e.g.
CCompilerDriver`$CCompiler = {
"Compiler" -> CCompilerDriver`IntelCompiler`IntelCompiler,
"CompilerInstallation" -> "/opt/intel/bin"
};
Mingw-w64 supports GCC on Windows for x86-64 targets. It is freely available through SourceForge.
After downloading the MinGW-W64 Online Installer from SourceForge, run the installer, choose 7 or higher for (GCC) Version, x86_64
for Architecture, posix
for Threads, and seh
for Exception. Be aware that the destination folder should not contain spaces.
With a destination folder of C:\mingw-w64\
, set $CCompiler
as follows:
CCompilerDriver`$CCompiler = {
"Compiler" -> CCompilerDriver`GenericCCompiler`GenericCCompiler,
"CompilerInstallation" -> "C:\\mingw-w64\\mingw64\\bin",
"CompilerName" -> "g++.exe"};
MSVC is available as part of Microsoft Visual Studio. MSVC 19.20 corresponds to the initial version of Visual Studio 2019. Alternatively, build tools for Visual Studio (available here) can be installed without the IDE.
To manually switch to MSVC, set $CCompiler
with the installation path, e.g.
CCompilerDriver`$CCompiler = {
"Compiler" -> CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler,
"CompilerInstallation" ->
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community"
};