MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

problems with dll library

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129410] problems with dll library
  • From: piotr <kalaipiotrek at gmail.com>
  • Date: Fri, 11 Jan 2013 22:24:24 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

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






  • Prev by Date: Re: Modern Differential Geometry for Mathematica 9
  • Next by Date: Mathematica and Lisp
  • Previous by thread: Re: Modern Differential Geometry for Mathematica 9
  • Next by thread: Mathematica and Lisp