1

私のOSはwindows7 64bitです。Microsoft C++ 2008 Express エディションと Intel C++ Compiler v11.1 x86 バージョンをインストールしました。

これで、Mathematica で x86 C コードを正常にコンパイルできました。

    In[1]:= Needs["CCompilerDriver`"]
    In[2]:= greeter = CreateExecutable[StringJoin["#include <stdio.h>\n", "int main(){\n", "  printf(\"Hello world.\\n\");\n", "}\n"], "hiworld", 
     "Compiler" -> CCompilerDriver`IntelCompiler`IntelCompiler, 
     "CompilerInstallation" -> "C:\\Program Files (x86)\\Intel\\Compiler\\11.1\\072\\", 
     "CompilerName" -> Automatic, "TargetSystemID" -> "Windows"]

    Out[2]= "C:\\...\\AppData\\Roaming\\Mathematica\\\
       SystemFiles\\LibraryResources\\Windows-x86-64\\hiworld.exe"

しかしCompilationTarget -> "C"、このような関数をコンパイルするために使用できませんでした

    In[3]:= f = Compile[{x, y}, Sqrt[x^2 + y^2], CompilationTarget -> "C"]

    During evaluation of In[3]:= LibraryFunction::libload: The function compiledFunction5 was not loaded from the file C:\\...\AppData\Roaming\Mathematica\ApplicationData\CCompilerDriver\BuildFolder\vax-5844\compiledFunction5.dll. >>
    During evaluation of In[3]:= Compile::nogen: A library could not be generated from the compiled function. >>

私のプラットフォームは x64 なので、デフォルトを指定する必要があると思います"TargetSystemID"-> "Windows"が、Mathematica でそのようなオプションを設定する方法がわかりません。

ここで何か見逃しましたか?

PS: 最近 Microsoft Visual Studio をインストールしたくありません。

4

1 に答える 1

1

最初のコード ブロックで、必要なコンパイラを指定しました。2 番目の場合は、そうではありませんでした。インストールしたコンパイラについて、Mathematica が「認識」していない可能性があります。

Needs["CCompilerDriver`"]次に実行CCompilers[Full]して、Mathematica が認識しているコンパイラを確認してください。また、グローバルを見てください$CCompilerDirectory

Intel および/または Microsoft コンパイラが表示されない場合は、 CCompilerDriver ユーザー ガイドの特定のコンパイラページに従ってください。Intel コンパイラを動作させるには、おそらく次の手順で十分だと思います。

$CCompiler = {
 "Compiler" -> CCompilerDriver`IntelCompiler`IntelCompiler,
 "CompilerInstallation"->"C:\\Program Files (x86)\\Intel\\Compiler\\11.1\\072\\"}

つまり、上記のコードを使用してコンパイラのディレクトリを間違ったものに変更した場合、最初に取得するエラーの種類 ( の前 Compile::nogen) はCreateLibrary::instlであり、LibraryFunction::libloadメッセージではありません。デフォルトのビルド ディレクトリに問題がある可能性があります: $CCompilerDefaultDirectory...

PS への回答として、Windows 用の Intel C++ v11.1 コンパイラは、テスト済みのコンパイラのリストに含まれているため、MS Visual Studio をインストールする必要はありません。一方、 MiniGW または CygWin を介してGCC for Windows を試すこともできます ( SO/187990も参照)。

于 2012-01-22T06:00:57.467 に答える