Group Abstract Group Abstract

Message Boards Message Boards

0
|
44.9K Views
|
21 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Run MinGW in Mac?

Posted 6 years ago

Hi, How can i run Min GW in Mac, do I need to rearrange these codes to make it run in Mac?

Can anyone please advise?

I posted the codes below.

Clear["Global`*"];
Needs["CCompilerDriver`GenericCCompiler`"];
$CCompiler = {"Compiler" -> 
    CCompilerDriver`GenericCCompiler`GenericCCompiler, 
   "CompilerInstallation" -> "C:\\MinGW", "CompilerName" -> "gcc.exe"};
CompileOptions = {CompilationTarget -> "C", 
   RuntimeOptions -> {"CatchMachineOverflow" -> False, 
     "CatchMachineUnderflow" -> False, 
     "CatchMachineIntegerOverflow" -> False, 
     "CompareWithTolerance" -> False, "EvaluateSymbolically" -> False,
      "RuntimeErrorHandler" -> Evaluate, "WarningMessages" -> False}, 
   CompilationOptions -> {"InlineExternalDefinitions" -> True, 
     "InlineCompiledFunctions" -> True, 
     "ExpressionOptimization" -> True}};

Thanks.

POSTED BY: adrian leong
21 Replies
POSTED BY: Szabolcs Horvát
Posted 6 years ago

Hi Peter I found the answer.

For Mac to run MinGW. Just install Xcode in terminal using xcode-select --install

In the Mathematica program ,delete: $CCompiler = {"Compiler" -> CCompilerDriverGenericCCompilerGenericCCompiler, "CompilerInstallation" -> "C:\MinGW", "CompilerName" -> "gcc.exe"};

The resulting code for the compiler is:

Clear["Global*"]; Needs["CCompilerDriverGenericCCompiler`"]; CompileOptions = {CompilationTarget -> "C", RuntimeOptions -> {"CatchMachineOverflow" -> False, "CatchMachineUnderflow" -> False, "CatchMachineIntegerOverflow" -> False, "CompareWithTolerance" -> False, "EvaluateSymbolically" -> False, "RuntimeErrorHandler" -> Evaluate, "WarningMessages" -> False}, CompilationOptions -> {"InlineExternalDefinitions" -> True, "InlineCompiledFunctions" -> True, "ExpressionOptimization" -> True}};

Just run it.

Thats it!

Thanks for your help also Peter! Regards Adrian

POSTED BY: adrian leong
Posted 6 years ago
POSTED BY: adrian leong
Posted 6 years ago
POSTED BY: adrian leong
Posted 6 years ago
POSTED BY: adrian leong

Is there any reason why you insist on setting up gcc instead of using the native compiler on macOS, i.e. clang, which comes with Xcode and requires zero configuration to get it working in Mathematica?

POSTED BY: Szabolcs Horvát
Posted 6 years ago

Thanks for reply, Ilian. But can the codes be modified to run gcc ?

I tried "Name:gcc.....Automatic" compile driver but it doesn't work.

I should be able to just replace it according to given line of compiled driver and run but it doesn't work either.

POSTED BY: adrian leong

I know, I actually tried to use it once for cross-compiling ... but it seemed more helpful to say that there isn't, since OP doesn't want to cross-compile.

POSTED BY: Szabolcs Horvát

There is no MinGW for macOS.

Technically there is (for cross-compiling), but that is not really relevant for OP's problem.

POSTED BY: Ilian Gachevski

There is no MinGW for macOS. You need to install Xcode from the Mac App Store instead. Once it's installed start it, and allow it to install the command line tools. Finally, test that clang (the compiler on macOS) works in a terminal.

After this, it will work with Mathematica without any special setup (i.e. do not create a special configuration).

Just try the examples for the CCompilerDriver package.

POSTED BY: Szabolcs Horvát
Posted 6 years ago

Dear Peter, Sorry for the long wait. I found a useful post in this matter, https://www.daniweb.com/programming/software-development/threads/66450/mingw-equivalent-for-osx

I'm working on it to see if it works.....

POSTED BY: adrian leong
Posted 6 years ago

Hi Peter, the compile sheet does not show error.

I need to cross check on my windows computer to see if the other sheet that requires this compilation to run is working properly.

I will write again.

Regards Adrian

POSTED BY: adrian leong

Hi Adrian, ok, what happens if you use "clang" instead of "gcc" in your mathematica script? kind regards, Peter

POSTED BY: Peter Ferschin
Posted 6 years ago
POSTED BY: adrian leong

Hi Adrian, hmm it seems that you have gcc installed, I just have the idea, that you might need a C compiler instead of gcc so try "clang" instead of "gcc". kind regards, Peter

POSTED BY: Peter Ferschin
Posted 6 years ago

Hi peter im not sure if you mean to check it this way. I checked in terminal Adrian-MM:~ user$ gcc --version Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1 Apple LLVM version 10.0.1 (clang-1001.0.46.4) Target: x86_64-apple-darwin18.5.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin Adrian-MM:~ user$

POSTED BY: adrian leong

Hi Adrien, can you test in terminal if you have gcc installed (see my previous post). One of the messages indicates that you have not... /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler kind regards, Peter

POSTED BY: Peter Ferschin
Posted 6 years ago
POSTED BY: adrian leong
POSTED BY: Peter Ferschin
Posted 6 years ago

Hi Peter I tried your suggestion but it didn’t work either and gave the same error.

POSTED BY: adrian leong

Hi Adrian,

You probably won't need MinGW as there is Terminal on the Mac. If you have an english system it should be in /Applications/Utilities/Terminal so I would try to replace "C:\\MinGW” with "/Applications/Utilities/Terminal" and "gcc.exe" with "gcc".

Kind regards,

Peter

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