On Wed, 09 Nov 2011 11:34:14 -0000, Alexander Vorobiev
<alexander.vorobiev at removethis.gmail.com> wrote:
> "Oleksandr Rasputinov" <oleksandr_rasputinov at hmamail.com> writes:
>
>> Personally, I use MinGW-w64 GCC
>> 4.6.1 rather than Visual C++; this works perfectly well also but does
>> require modifications to Mathematica which I will not discuss here other
>> than to say that it would be nice if this compiler could be supported
>> without need of modifications in a future release.
>
> The way to deal with MinGW-w64 is described in the documentaion.
> Specifically,
> either define $CCompiler:
>
> Needs["CCompilerDriver`"]
>
> Needs["CCompilerDriver`GenericCCompiler`"]
>
> $CCompiler = {"Name" -> "MinGW64", "Compiler" -> GenericCCompiler,
> "CompilerInstallation" -> "C:/MinGW64",
> "CompilerName" -> "x86_64-w64-mingw32-gcc.exe"};
>
> or use the options, e.g.
>
> greeter = CreateExecutable[StringJoin[
> "#include <stdio.h>\n",
> "int main(){\n",
> " printf(\"Hello MinGW-w64 world.\\n\");\n",
> "}\n"],
> "hiworld", "Compiler" -> GenericCCompiler,
> "CompilerInstallation" -> "C:/MinGW64",
> "CompilerName" -> "x86_64-w64-mingw32-gcc.exe"]
>
Treating MinGW-w64 as a generic compiler as described in the documentation
gives one the ability to call it from Mathematica, but does not enable the
same level of functionality available with compilers for which proper
support has been provided. For example, apart from the CUDA issue you
noticed, nothing using MathLink or the Wolfram Library runtime will work
either because libraries have not been provided for this.
CCompilerDriver`GenericCCompiler.m avoids link errors only because it does
not attempt to link with any libraries. In other words, the approach
suggested in the documentation achieves only barely minimal support and is
not enough for proper operation. For example:
In[1]:=
Needs["CCompilerDriver`"];
In[2]:=
(* With proper support *)
$CCompiler=CCompilerDriver`MinGWCompiler`MinGWCompiler;
CreateLibrary[
{"C:\\Program Files\\Wolfram
Research\\Mathematica\\8.0\\SystemFiles\\Links\\LibraryLink\\LibraryResources\\Source\\demo_mathlink.c"},"demo_mathlink"
]
Out[3]=
"C:\\Users\\Oleksandr\\Application
Data\\Mathematica\\SystemFiles\\LibraryResources\\Windows-x86-64\\demo_mathlink.dll"
In[4]:=
(* Using GenericCCompiler` as suggested in the documentation *)
$CCompiler={"Name"->"MinGW64","Compiler"->CCompilerDriver`GenericCCompiler`GenericCCompiler,"CompilerInstallation"->"C:\\MinGW-w64","CompilerName"->"x86_64-w64-mingw32-gcc.exe"};
CreateLibrary[
{"C:\\Program Files\\Wolfram
Research\\Mathematica\\8.0\\SystemFiles\\Links\\LibraryLink\\LibraryResources\\Source\\demo_mathlink.c"},"demo_mathlink",
"ShellOutputFunction"->Print
]
During evaluation of In[5]:=
C:\MinGW-w64\bin\x86_64-w64-mingw32-gcc.exe -shared -o
"C:\Users\Oleksandr\Application
Data\Mathematica\SystemFiles\LibraryResources\Windows-x86-64\Working\demo_mathlink.dll"
-I"C:\Program Files\Wolfram
Research\Mathematica\8.0\SystemFiles\IncludeFiles\C" -I"C:\Program
Files\Wolfram
Research\Mathematica\8.0\SystemFiles\Links\MathLink\DeveloperKit\Windows-x86-64\CompilerAdditions\mldev64\include"
"C:\Program Files\Wolfram
Research\Mathematica\8.0\SystemFiles\Links\LibraryLink\LibraryResources\Source\demo_mathlink.c"
-L"C:\Program Files\Wolfram
Research\Mathematica\8.0\SystemFiles\Links\MathLink\DeveloperKit\Windows-x86-64\CompilerAdditions\mldev64\lib"
-L"C:\Program Files\Wolfram
Research\Mathematica\8.0\SystemFiles\Libraries\Windows-x86-64" 2>&1
C:\Users\Oleksandr\Temp\ccCKP9sc.o:demo_mathlink.c:(.text+0x54): undefined
reference to `MLCheckFunction'
C:\Users\Oleksandr\Temp\ccCKP9sc.o:demo_mathlink.c:(.text+0x70): undefined
reference to `MLGetInteger'
C:\Users\Oleksandr\Temp\ccCKP9sc.o:demo_mathlink.c:(.text+0x84): undefined
reference to `MLGetInteger'
C:\Users\Oleksandr\Temp\ccCKP9sc.o:demo_mathlink.c:(.text+0x94): undefined
reference to `MLNewPacket'
C:\Users\Oleksandr\Temp\ccCKP9sc.o:demo_mathlink.c:(.text+0xb7): undefined
reference to `MLPutInteger'
C:\Users\Oleksandr\Temp\ccCKP9sc.o:demo_mathlink.c:(.text+0x1bc):
undefined reference to `MLCheckFunction'
C:\Users\Oleksandr\Temp\ccCKP9sc.o:demo_mathlink.c:(.text+0x1d8):
undefined reference to `MLGetString'
C:\Users\Oleksandr\Temp\ccCKP9sc.o:demo_mathlink.c:(.text+0x1e8):
undefined reference to `MLNewPacket'
C:\Users\Oleksandr\Temp\ccCKP9sc.o:demo_mathlink.c:(.text+0x20c):
undefined reference to `MLPutString'
C:\Users\Oleksandr\Temp\ccCKP9sc.o:demo_mathlink.c:(.text+0x23f):
undefined reference to `MLReleaseString'
collect2: ld returned 1 exit status
Out[5]= $Failed