09-03-2011 07:34 AM
Hello, experts
I need to use FingerLakeInstrument DLL ( see the attached) inside Labview to talk to a CCD camera. it is built from microsoft visual studio C++
I unzip FLI dll in my D:\proj\...\linfli-32 and import dll from there. created a c:\FLIDBG.txt as FLI dll needs to write debug message to it if FLISetDebugLevel() or others are called.
During importing the dll, first thing I got is <sys/types.h> ( ie size_t ) cannot be found. I have installed free version of microsoft visual studio C++
but can not find "typedef unsigned int size_t"
at the end, I just added
typedef unsigned int size_t;
in the libfli.h. Having done that, I am able to import all functions into Labview and have a user library called libfli.
However, as soon as I start calling a simple function in a test.vi, such as FLIGetLibVersion(char* ver, size_t len), which involves nothing other than the library, the labview will crash.
I created a simple C test.exe which calls many functions without any problem
any suggstion?
regards
xiaofeng
Solved! Go to Solution.
09-04-2011 01:25 PM
You have not shown us what the LabVIEW code looks like. The size_t parameter refers to the length of the buffer you are passing in. In this case you are passing in a string. So, presumably, you've created a buffer in LabVIEW of a string of sufficient size, and you are setting the "len" parameter to be the length of that string. Have you also check to make sure you are using the correct calling convention?
09-04-2011 06:01 PM
Hi, Smercurio_fc
thanks for your reply. Yes, you are pointing to the right place. I have solved the crash problem.
when importing DLL into Labview using Tools\import\Shared Library (.dll), Labview automatically set the calling convention as C not as stdcall (WINAPI). it is this that later the labview crashes when a function is called. as soon as I manually re-selecte calling convention as stdcall, my test.vi works OK (see attached).
I tried Call Library Function too to call libfli.dll, as long as I select stdcall as call convetion. the test.vi works.
How do I know which Call convention I need to choose if there is no infomation from DLL provider?
as for the size_t,
I add #include <crtdefs.h> in libfli.h and
add additional include path as
C:\Program Files\Microsoft Visual Studio 10.0\VC\include. this solved the "not found" issue.
for this case I know that the DLL is built from VC++, is this right way?
again, thanks for your time.
xiaofeng
09-05-2011 08:12 AM
There really is no "right" way. You just need to provide a header file that has the definition for that type. The header files that ship with VC are perfectly fine.
As for the calling convention, you can sometimes figure it out by looking at the export symbols to see the names of the functions. I don't remember all the rules, but if the name starts with an underscore and has no additional text after the name you see, then it's C calling convention. If it has additional characters then I think it's stdcall.
09-05-2011 10:06 AM
thanks for the infomation.
cheers
xiaofeng
03-13-2012 10:06 AM
Hello,
I am trying to use FLI dll to control a FLI Microline camera. I think you did ir before, I would appreciate if you can help me with this. I am using the call library function node, and define the calling conversion as stdcall. When trying to use the different functions, I do not know how to define in LabView some parameters of the function, for example:
"LIBFLIAPI FLIOpen (flidev t* dev, char* name, flidomain t domain)
dev Pointer to where a device handle will be placed.
name Pointer to a string where the device filename to beopened is stored. For parallel port devices that are not probed byFLIList() (Windows 95/98/Me), place the address of theparallel port in a string in ascii form ie: ”0x378”.
domain Domain to apply to name for device opening.This is a bitwise ORed combination of interface method and devicetype. Valid interfaces include FLIDOMAIN PARALLEL PORT,FLIDOMAIN USB, FLIDOMAIN SERIAL, andFLIDOMAIN INET. Valid device types includeFLIDEVICE CAMERA, FLIDOMAIN FILTERWHEEL, andFLIDOMAIN FOCUSER.
How can I define pointers?
Thank you for your help!