11-02-2011 11:17 AM - edited 11-02-2011 11:20 AM
I've just been through th chapters 2 and 3 on here...
http://www.ni.com/pdf/manuals/370109a.pdf
I've created the myshared.c file (attached)
and I've compiled is using
gcc -fPIC -shared -o myshared.dll myshared.c
and there are no errors.
However when I try and selet the myshared.dll I am getting a "The file selected is not a valid library"
Have I missed something?
/* Call Library source file */
#include "extcode.h"
long avg_num(float a[], long size, float *avg);
long avg_num(float a[], long size, float *avg)
{
int i;
float sum=0;
if(a != NULL)
{
for(i=0;i < size; i++)
sum = sum + a[i];
}
else
return (1);
*avg = sum / size;
return (0);
}
11-02-2011 11:29 AM
That is an extremely old and obsolete document. The latest version of that document is actually contained within the LabVIEW Help file. Do you have the Professional edition of LabVIEW, or do you have the Full with the Application Builder? If so, you use that to create a DLL via a project. Please review the updated documentation. Also, forget the bit about CINs. That's obsolete technology.
You can also review this: https://decibel.ni.com/content/docs/DOC-15556
11-02-2011 11:48 AM
That link seems to document how to turn VI in to DLL.
I'm looking to turn .c files in to DLL.
11-02-2011 01:14 PM
Sorry, misunderstood what you were trying to do. Still, the document you have is way old and you should review the updated documentation that is in the LabVIEW Help on calling DLLs.
Have you tested the DLL by calling it from a C program? What operating system are you using? Which version of gcc? Which version of LabVIEW (it looks like 2010 or 2011)? Are you compiling 32-bit or 64-bit? Does your LabVIEW bitness match?
11-03-2011 04:29 AM
I'm using Windows 7 x64
Labview 201 x86
and GCC-2.96 on linux.
Do i need to include winthe Windows.h file?
11-03-2011 07:56 AM - edited 11-03-2011 08:04 AM
@Richard_Ha wrote:
I'm using Windows 7 x64
Labview 201 x86
and GCC-2.96 on linux.
Umm... hold on. Are you trying to compile a Windows DLL on a Linux machine? Using what, Wine? I'm assuming you are, or you're doing something else. Is there any reason why you don't compile the DLL in Windows directly?
And the correct spelling of "Labview" is LabVIEW. We're picky about that around here.
EDIT: One thought that I had: Are you trying to cross-compile? I'm not sure about gcc, but the little that I've seen in the past regarding cross-compilation seemed to favor mingw over gcc, but I do not know the technical reasons for it, or whether it was just a "flavor of the week".
11-03-2011 10:45 AM
I've managed to get the dll file compile in Visual Studio and it working so I will just do that from now on!
It has yeielded some interestinf results, but that's for another thread!
Thank for the help.