LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using a cygwin DLL in LabVIEW 7.0

Hallöchen!

I try to use a function from a cygwin DLL in a LabVIEW 7.0 VI. So
I wrote

void funcName(double values[], long number_values)
{
for (int i=0; i < number_values; i++) values[i] /= 2.0;
}

to the file test.cc and said (cygwin gcc 3.3.1)

gcc -c test.cc
gcc -shared -o hall.dll test.o

Then I included it as a shared DLL in LabVIEW, added the correct
parameter sequence and return value. The name of the function was
a little bit different (Z8funcNamePdl).

But: LabVIEW crashes every single time. Not matter what I say about
calling convention or reentrance. As soon as the "configure" window
is closed, *all* LabVIEW windows are closed.

What am I doing wrong?

Thank you!

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa
vetus
0 Kudos
Message 1 of 8
(3,809 Views)
How are you passing the array in? LabVIEW arrays have a different structure than the traditional C arrays. As a quick test, try passing in a single DBL value by pointer for the first argument, and 1 for the second argument. This will hack LabVIEW into passing the right type into your C function, but it only works for one value.

The prototype in your C function needs to match the prototype you get from the "Create C File..." Dialog. There's a PDF document included in LabVIEW that goes into detail about LabVIEW arrays with external code.
0 Kudos
Message 2 of 8
(3,809 Views)
Hallöchen!

LarsRoe writes:

> [...] LabVIEW arrays have a different structure than the
> traditional C arrays. As a quick test, try passing in a single
> DBL value by pointer for the first argument, and 1 for the second
> argument.

Even a "void Test()" lets LabVIEW crash. I now say

extern "C" {
void Test();
}

void Test() {
return;
}

> The prototype in your C function needs to match the prototype you
> get from the "Create C File..." Dialog.

Granted, but quoting the gcc manual: "Good compilers never crash."
I didn't *start* the VI after all.

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus
0 Kudos
Message 3 of 8
(3,809 Views)
LabVIEW shouldn't crash just loading the DLL (not running it).

Can you call the DLL from other applications (e.g. a simple C program)? Can you attach the DLL? Thanks,

Lars
0 Kudos
Message 4 of 8
(3,809 Views)
Hallöchen!

LarsRoe writes:

> LabVIEW shouldn't crash just loading the DLL (not running it).
>
> Can you call the DLL from other applications (e.g. a simple C
> program)?

Yes, I created the DLL (and the test program) according to
<>. The dll is linked
to the test program dynamically, so deleting the dll prevents the
program from working.

> Can you attach the DLL?

Sure, you find it here:

http://www-users.rwth-aachen.de/torsten.bronger/mydll.dll

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus
0 Kudos
Message 5 of 8
(3,809 Views)
Hallöchen!

LarsRoe writes:

> LabVIEW shouldn't crash just loading the DLL (not running it).

So is the whole thing a candidate for a bug report?

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus
0 Kudos
Message 6 of 8
(3,809 Views)
I just downloaded the cygwin1.dll, and I'm getting the same issue.

It's hard to know what's to blame (LabVIEW, your DLL, Cygwin DLL, or some incompatibility) since it's all part of the same application, but it looked like it was the thread into the Cygwin dll that was crashing.

One thing to try is to call the DLL from a different application besides LabVIEW. Have you tried that?

-Lars
0 Kudos
Message 7 of 8
(3,809 Views)
Hallöchen!

LarsRoe writes:

> [...]
>
> One thing to try is to call the DLL from a different application
> besides LabVIEW. Have you tried that?

Which application could that be?

Well, a trivial EXE file generated with Cygwin can use it. As far
as I can tell, Cygwin has no own DLL file format.

However, I have no other development tool for creating a program.

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus
0 Kudos
Message 8 of 8
(3,809 Views)