1

私のOSはWindows 7 64bitです。私はMicrosoft C++ 2008 Express EditionとIntel C++ Compiler v11.1 x86バージョンをインストールしました。Win7(x64)でintel C++コンパイラ(x86)を使ってMathematicaをCコードにコンパイルする方法

これで、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" 

しかし、この

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. >> 

のような機能をコンパイルするCompilationTarget -> "C"を使用することができなかった私は私のプラットフォームはx64のであるから、私はデフォルト"TargetSystemID"-> "Windows"を指定する必要があると思いますが、そのようなANを設定する方法がわかりませんMathematicaのオプション。

私はここで何か不足しましたか?

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

答えて

1

first code blockには、必要なコンパイラを指定しました。 2番目にはありませんでしたので、Mathematicaはあなたがインストールしたコンパイラについて「認識」していないかもしれません。

Needs["CCompilerDriver`"]を実行し、CCompilers[Full]を実行して、Mathematicaが知っているコンパイラを確認してください。グローバル$CCompilerDirectoryもご覧ください。

インテルまたはマイクロソフトのコンパイラが表示されない場合は、CCompilerDriver User GuideSpecific Compilersページに従ってください。インテルコンパイラ作業を取得するには 、私は多分、次は十分なはずだと思う:

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

言った - 私は何か間違って、私は取得後、最初のエラータイプに私のコンパイラにディレクトリを変更するには、上記のコードを使用している場合(Compile::nogenより前)はというメッセージではなく、CreateLibrary::instlです。 $CCompilerDefaultDirectory ...

あなたのPSに対応して、Windows用のインテル®C++ v11.1コンパイラーはテスト済みのコンパイラーのリストにありますので、必要はありませんMS Visual Studioをインストールします。一方、MiniGWまたはCygWin経由でWindows用のGCCを試すこともできます(SO/187990も参照)。

関連する問題