Message Boards Message Boards

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

Run MinGW in Mac?

Posted 5 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

That is exactly what I said 6 months ago ...

Also, what you installed is not MinGW. The tool called MinGW, "Minimalist GNU for Windows" is used to compile programs for Windows only.

POSTED BY: Szabolcs Horvát
Posted 5 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 5 years ago

Ya, also now I learned that there's no MinGW is not available in Mac, the thread title is misleading as well. I guess it's fine.

POSTED BY: adrian leong
Posted 5 years ago

im trying to run a model written by my friend to simulate some experimental data i measured. he told me that i need to run the compiler first in gcc. he wrote it in windows which needs MinGW package.

Alternatively, I would like to know how to do it with clang in mac using the same file as im using mac, i don't want to boot camp my laptop. it sounds like a better method. i looked around but i don't understand how the native compiler in macOS works. I installed Xcode but i don't know how one can run native compiler on a mathematica nb without opening it and evaluate cell containing the compiler in terminal.

I really appreciate it if there's instructions how to do it.

POSTED BY: adrian leong
Posted 5 years ago

Thanks for reply, Szabolcs.

Ya, its annoying and confusing.

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 5 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 5 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 5 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 5 years ago

Hi Peter,

Adrian-MM:~ user$ clang --version 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$

Im not sure what is going wrong, xcode is installed also.

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 5 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 5 years ago

Hi Peter the error : CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >> CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >> CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >> CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >> CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >> CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >> CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >> CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >> CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >> CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >> CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >> CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >> CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >> CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> /Applications/Utilities/Terminal does not indicate a usable installation of Generic C Compiler. >> Compile::nogen: A library could not be generated from the compiled function. >>

Then, I changed the compiler installation directory to /usr/bin it does not show error but the compilation still does not work.

POSTED BY: adrian leong

Hi Adrian, can you specify the error in detail? Do you have gcc installed? Open the Terminal application and enter gcc and hit return, do you get an error? If yes, you need to install gcc first (e.g. with brew https://brew.sh) kind regards, Peter

POSTED BY: Peter Ferschin
Posted 5 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

Group Abstract Group Abstract