2

I am unable to set up the C compiler on my computer, thus can't not make the option CompilationTarget-"C" work in Compile. I am using windows 8 system.

At first, I install VS2013 express. CCompilers[Full] shows that mma has detected it.

{"Name" -> "Visual Studio", 
 "Compiler" -> 
  CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler, 
 "CompilerInstallation" -> 
  "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0", 
 "CompilerName" -> Automatic}

But compilation always gives errors like this

CCompilerDriver`CreateLibrary::cmperr: Compile error: LINK : fatal error LNK1104: ÎÞ[CenterDot]¨.b4ò¿ªÎļþ¡[Degree]LIBCMT.lib¡[PlusMinus] >>

Compile::nogen: A library could not be generated from the compiled function. >>

After searching, I actually didn't find any LIBCMT.lib file.

Then, I took advice to try to install windows sdk. Unfortunately, the installation failed, don't know why!!!!

Finally, according to Specific compiler documentation page. I tried Mingw-64. Then installation is fine. But the mma seems just can't detect it. For CCompilers[Full] shows

{"Name" -> "Generic C Compiler", 
 "Compiler" -> CCompilerDriver`GenericCCompiler`GenericCCompiler, 
 "CompilerInstallation" -> None, "CompilerName" -> Automatic}

So I run the following

$CCompiler = {"Compiler" -> 
    CCompilerDriver`GenericCCompiler`GenericCCompiler, 
   "CompilerInstallation" -> 
    "c:/Program \
Files/mingw-w64/x86_64-5.2.0-win32-seh-rt_v4-rev0/mingw64", 
   "CompilerName" -> "x86_64-w64-mingw32-gcc.exe"};

But except change the default compiler, "CompilerInstallation" still shows "none" and running compiled code gives errors

Compile::nogen: A library could not be generated from the compiled function. >>

Need help. I really don't know how to do it right.

matheorem
  • 17,132
  • 8
  • 45
  • 115
  • I'm voting to close this question as off-topic because it does not relate to the Mathematica programming language. – Bob Hanlon Oct 12 '15 at 15:18
  • @BobHanlon I modified my question title, maybe now it is much related to mathematica – matheorem Oct 12 '15 at 15:28
  • I retracted my vote and will leave it up to others. – Bob Hanlon Oct 12 '15 at 15:31
  • I would try this: First, I would make sure to install mingw in a directory with no spaces in its path. Then, I would try to CreateLibrary example from the documentation, making sure to set the shell command function and shell output function to Print, to have some idea about how Mathematica is calling the compiler and what errors the compiler might be reporting. Also, binaries created by some versions of this compiler need additional DLLs to run. Once compilation is successful, these may still need to be loaded with LoadLibrary for the library to be able to load successfully ... – Szabolcs Oct 12 '15 at 15:39
  • 4
    Also, search this site for more MinGW-64 posts which can provide hints. http://mathematica.stackexchange.com/q/55034/12 If you solved it, please write a self-answer. – Szabolcs Oct 12 '15 at 15:42
  • @Szabolcs Following that link step by step solves my problem, many thanks, Szabolcs! Maybe my question can be deleted now. – matheorem Oct 12 '15 at 16:19
  • @matheorem Do you mean Leon Avery's post? Did you reinstall mingw in a location with no spaces in the path? I'm asking because I'm going to have to do this myself soon ... – Szabolcs Oct 12 '15 at 16:22
  • @Szabolcs Yeah, I mean Leon Avery's post. I reinstall the mingw with no spaces. I should have tested it without reinstalling, but that is too late after I press the uninstall button :) I think maybe the key is to set path and library_path, and of course $$CCompiler – matheorem Oct 12 '15 at 16:36

0 Answers0