1

Problem: I have cyrylic symbols in my $UserBaseDirectory. As result temporal directory for CreateExecutableand friends is in my$UserBaseDirectory`. Which produce error.

Code:

Needs["CCompilerDriver`GenericCCompiler`"]

greeter = CreateExecutable[
  StringJoin["#include <stdio.h>\n", "int main(){\n", 
   "  printf(\"Hello MinGW-w64 world.\\n\");\n", "}\n"], "hiworld", 
  "Compiler" -> GenericCCompiler, 
  "CompilerInstallation" -> "C:/MinGW-64", 
  "CompilerName" -> "x86_64-w64-mingw32-gcc.exe"
  ]

produce error

CreateExecutable::cmperr: Compile error: x86_64-w64-mingw32-gcc.exe: error: C:\Users\¦Ð¦\[Not]¦¦¦¦TÁ¦-¦-¦+TÀ\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Windows-x86-64\Working-pc6807-6420-5640-3\hiworld.c: No such file or directory >>

but

Needs["CCompilerDriver`GenericCCompiler`"]
greeter = CreateExecutable[
  StringJoin["#include <stdio.h>\n", "int main(){\n", 
   "  printf(\"Hello MinGW-w64 world.\\n\");\n", "}\n"], "hiworld", 
  "Compiler" -> GenericCCompiler, 
  "CompilerInstallation" -> "C:/MinGW-64", 
  "CompilerName" -> "x86_64-w64-mingw32-gcc.exe",
  "WorkingDirectory"\[Rule]"c:\\1\\",
  "TargetDirectory"\[Rule]"c:\\2\\"
  ]

work fine.

Is there way to setup default value for "WorkingDirectory" and "TargetDirectory" for function like CreateExecutable?

molekyla777
  • 2,888
  • 1
  • 14
  • 28

1 Answers1

1

There is undocumented function which return working (temporary) and target

CCompilerDirectories[]
(*{C:\Users\Александр\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Windows-x86-64,C:\Users\Александр\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Windows-x86-64\Working}*)

DownValues of this function say that $CCompilerDefaultDirectory use for setup working and target directories

DownValues[CCompilerDirectories]
{HoldPattern[CCompilerDirectories[]]:>With[{CCompilerDriver`Private`target=$CCompilerDefaultDirectory},{CCompilerDriver`Private`target,FileNameJoin[{CCompilerDriver`Private`target,Working}]}]}

And then set $CCompilerDefaultDirectory as you wish.

PS: easier way is to studie documentation

$CCompilerDefaultDirectory returns the default location for creating output.

but we are not looking for easy ways =)

molekyla777
  • 2,888
  • 1
  • 14
  • 28