Date: Jan 11, 2013 10:23 PM
Author: kalaipiotrek@gmail.com
Subject: problems with dll library
Hi,

I have proble which I can not solve for a long time...

I use MinGW compiler to generate dll library - I use a following command to compile a code:

gcc -Wall -shared libraryX.c -o libraryX.dll

in the libraryX.c I put a simple function:

double signX( double x ) {

double s = 0.0;

/*Funtion body*/

if( x > 0.0) s = 1.0;

if( x < 0.0) s = -1.0;

return(s);

}

When I am trying to use this function in Mathematica with a command:

Needs["NETLink`"]

signX = DefineDLLFunction["signX", "libraryX.dll", "double", {"double"}];

signX[1.0]

I get a following error:

NET::netexcptn:

"A .NET exception occurred: \!\(\"System.BadImageFormatException: Probowano zaladowac program w niepoprawnym formacie.

(Wyj\\:0105tek od HRESULT: 0x8007000B)\\n w

Wolfram.NETLink.DynamicDLLNamespace.DLLWrapper16.signX(Double )

Does anybody know how to load such simple funtion in mathematica?

I would be garteful for some hints.

Regards,

Piotr