LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Import Shared Library Wizard: Declarations not found

Solved!
Go to solution

Hey, I have proprietray C code and header files that I want to use in LabVIEW. As LabVIEW suggested, I used the Wizard to create the wrappers. I worked my way through the wizard, and in the step Select Functions to Convert, I get the message 

"The shared library contains 342 function(s). The declarations of 235 function(s) are found and recognized in the header file and these function(s) can be wrapped. The remaining function(s) cannot be wrapped.".
The error messages next to the functions that could not be wrapped say that various symbols are not defined: DOUBLE, DWORD, TASKID, LPCSTR, BuildResult, etc. It also says that a header is missing ("wtypes.h"). 
Now, my C knowledge is (very) sparse, but I guess that I need to define DOUBLE, DWORD, etc. in the preprocessor in the Wizard. I am also guessing that the file "wtypes.h" is not shipped with the rest as this would then allow anyone to build the wrappers and not buy their ready-to-use USD$800 LabVIEW vi's.

Any hints what I must do to get ful functionality?

Cheers
Doug

0 Kudos
Message 1 of 10
(3,305 Views)

I can't edit my OP, so here's an edit...

EDIT: Essentially, I need to know what to put in the "Preprocessor Definitions" field in the attached picture. Something of the sort DOUBLE=_dbl. Again my knowledge of C hinders me from advancing here. Is my interpretation of what the problem is correct?

I would have included the c functions and headers, but like I said its proprietary and I fear that might breach some distributing clauses...

0 Kudos
Message 2 of 10
(3,287 Views)

The following link includes some examples of what the Preprocessor Definitions Pages expects. Let me know if this helps:

http://zone.ni.com/reference/en-XX/help/371361J-01/lvdialog/dll_config_paths/

 

Alex C. 

National Instruments 

Applications Engineer

 

Alex C.
Applications Engineering
National Instruments
Message 3 of 10
(3,238 Views)

These definitions are standard types declared in the Windows SDK headers. As such it is not a trick from the manufacturer to force you into buying their ready made LabVIEW library but simply normal expectation that anyone who would use this header with a C compiler to write a Windows application must have the Windows SDK headers somewhere on his system, so that the C compiler can compile and build an executable at all.

 

Now downloading the Windows SDK from Microsoft is a fairly big download and installing it on your system can be quite a task. Getting the Import Library Wizard to know where to find those files is also some task.

So if there are only a few types missing it is indeed the easiest solution to just add them manually to the Import Library Wizard configuration. This page from Microsoft (found by googling "Windows data types" as the link will likely go stale after some time due to MS restyling their webservers regularly) lists the most common types and also shows the actual definition in terms of basic C datatypes.

 

Rolf Kalbermatter
Averna BV
Message 4 of 10
(3,229 Views)

Thanks SirKnee and rolfk for your replies. 
@SirKnee I've also found the LabVIEW help for the wizard and I know that I will have to write the definitions into the preprocessor. I just don't know what to write in there...

 

@rolfk That link looked promising, but again, what do I do with what it says there? Do I put, for example,  "LPCSTR=__nullterminated CONST CHAR *LPCSTR" into the preprocessor definition in the LabVIEW wizard (as it says here: Windows Data Types)? I tried this and the wizard comes back with the same amount of functions...

0 Kudos
Message 5 of 10
(3,209 Views)

Ok so after some more trying I am now at 314/342 functions successfully wrapped. All I wrote in the preprocessor defintion was DOUBLE=double. What I am missing now is:

LPCSTR (on microsoft site: "typedef __nullterminated CONST CHAR *LPCSTR;"),

ULONG ("typedef unsigned long ULONG;").

size_t (NOT CAPITALISED!?!?!?!) ("typedef ULONG_PTR SIZE_T;"),

BuildResult (I'm guessing that pretty specific, but can probaly live without it),

A3200 Added Program (again to specific, so wont be needed),

TASKID (couldn't find any help on that...).

Am I on the right track with this?
Thanks for your help

 

0 Kudos
Message 6 of 10
(3,206 Views)
Solution
Accepted by topic author bockdoug

LPCSTR=const char*                   # Is simply a constant C string pointer

ULONG=unsigned long                # an unsigned long integer

size_t=                                          # this is a tricky one since C99 doesn't define a specific size other than it is at least a 16 bit unsigned integer. Looking in the Windows standard C headers (intsafe.h) you see that it is "unsigned __int64" for 64 bit Windows and "unsigned int" for 32 bit Windows. Best would be to go afterwards into the VIs and change this type explicitedly into "pointer sized unsigned integer" yourself.

TASKID=UINT64=unsigned __int64=unsigned long long

 

A quick test seems to indicated that the import library wizard recognizes both the Microsoft C specific "__int64" and the more general "long long" as a 64 bit integer.

 

BuildResult is not a standard Windows type definition, nor is TASKID strictly speaking. TASKID is a mscorelib type which is the core library for .Net.

 

All lower_case_t (including size_t) types are new C99 datatypes that the import library wizard does not seem to know about. As pointed out for the size_t type it can be also tricky to try to support that out of the box without even more configuration options in the wizard.

 

Extra note: After long and fruitless search I accidentially stumbled over this page here, which actually documents the recognized datatypes the Import Library Wizard knows about. It doesn't seem to talk about things like __stdcall and __cdecl which it obviously also understands. And it has two typos where it uses Char and Struct where it should also just use the lowercase form of it.

Rolf Kalbermatter
Averna BV
Message 7 of 10
(3,200 Views)

Following rolfk's advice, I've downloaded and installed the Microsoft SDK. Then, in the wizard again, I selected the path to the directory in the SDK where the headers are stored ("C:\Program Files\Microsoft SDKs\Windows\v7.1\Include").  This gave me 320 out of a total of 342 functions (getting there...)! However LPCSTR is still undefined and I can't work out what to define it as...

0 Kudos
Message 8 of 10
(3,196 Views)

YIPPPEEEE!!! 342/342!

So what worked it in the end was the Microsoft SDK as well as the preprocessor definition LPCSTR=const chat*.
Thanks for your help!

0 Kudos
Message 9 of 10
(3,195 Views)

It's strange that LPCSTR can't be resolved when including the Windows SDK headers. It's right there in wtypes.h and at least in my version without any conditional defines around it or its dependent declaration of the CHAR datatype.

Rolf Kalbermatter
Averna BV
0 Kudos
Message 10 of 10
(3,186 Views)