LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Create an Import Library for a DLL

Hi there! According to Knowledgebase 1ZQELEY5: How Do I Create an Import Library for a DLL in LabWindows/CVI? I tried to do so for Micro-Epsilons LibOpto.dll which I would like to use with the PCI IF 2004 card and two optoNCDT 2200 Laser Optical Displacement Sensors. The LibOpto.dll and LibOpto.h files are provided from Micro-Epsilon's download page including the descriptions of the function prototypes in the manual.

Now my problem is that I get an error stating: Unable to create import library. Error in header file...

I guess this means that the provided header file doesn't match the dll file.

So what can I do besides figuring out manually what functions are exported from the dll (KnowledgeBase 1ZQDQPY5: How Do I Link to Functions Defined in a Dynamically Linked Library (DLL) fr...)?

Any hints would be appreciated...

Regards whoknows
0 Kudos
Message 1 of 15
(5,552 Views)
The second link in my first post was not correct... I meant
How to Use an External DLL in LabWindows/CVI When Not Given a Header File
Since I'm given all the function prototypes I should be able to do that manually so I'll try this now and hope I'll get it working...

0 Kudos
Message 2 of 15
(5,528 Views)
Have you tried creating a simple project that includes LibOpto.h but does not call any of the functions in it?  The idea is to try and run LibOpto.h through the cvi compiler to see if there are any dependancies or other issues within the header file that can be easily corrected.
0 Kudos
Message 3 of 15
(5,518 Views)
Hi mvr, thanks for your reply!

I tried that as well and got an error on the exact same position as with "Generate DLL Import Liberary...". A closer look at the header file didn't reveal any "simple" problems to me. So I thought about trying to compile one of the M$ VS C++ 6.0 example projects delivered with the dll to see if I get problems there as well. A colleague did this for me an he had no problems at all.

I have to mention that I'm not really accustomed to this C/C++ stuff so I could imagine that I miss some basic concepts of this dll and header story.  0_o
My next guess would be that there are differences between a c and a c++ function definition causing my problem...

LibOpto.h:
...
LIBOPTO int OptoPCI_OpenDriver ( char szShortPath[260] );
LIBOPTO int OptoPCI_CloseDriver ( );
LIBOPTO int OptoPCI_DAQ_Info ( VXD_VERSION_INFO *VersionInfo );
LIBOPTO int OptoPCI_DAQ_Parameter ( WORD id, WORD ChanNo, WORD ChanPos[4], UINT SensorType[4], UINT SensorRange[4], double Autozero[4], WORD BlockSize, BOOL encoderOnFIFO, BOOL useGate, WORD sensor);
...

Now, the error I get is on "OptoPCI_DAQ_Parameter ( WORD id, ..." where the compiler states:   "LibOpto.h"(89,42)   syntax error; found 'identifier' expecting ')'.
The first three functions pass. Could it be that there has to be a typedef struct for the whole thing as there is for VXD_VERSION_INFO?

LibOpto.h:
...
typedef struct
{
   short IfcVersion;
   short FeatureFlags;
   char  VersionString[40];
} VXD_VERSION_INFO;
...

I'll dig into some books over the weekend... might be that my problems will solve themselves...


0 Kudos
Message 4 of 15
(5,514 Views)

If you have the full version of CVI and have installed the windows sdk add the line

#include "windows.h" in libOpto.h.  This adds some of the windows definitions needed to use this header.  With a little luck this should allow you to generate the type library.

If you don't have the full version of cvi  you can download the Windows Platform SDK directly from Microsoft.

Message Edited by mvr on 04-28-2006 10:13 AM

0 Kudos
Message 5 of 15
(5,513 Views)
It worked!
Now I was able to build the library file, thanks a lot! But what was exactly the problem? Windows specific calls?

Hope I'll get along with the rest... next week 😉

Regards


0 Kudos
Message 6 of 15
(5,495 Views)

Windows specific type definitions like WORD and UINT.  Including windows.h takes care of this.  One thing to note, if you ever need to add windows.h to any of your source files in CVI, make sure that you add it before any of the CVI header files.  The windows definitions must be included first.

Good Luck!

 

0 Kudos
Message 7 of 15
(5,489 Views)

If you use the version of libOpto.h that includes windows.h, it should be one of the first headers loaded by your c source file.  If you want to use the original unmodified libOpto.h, just include windows.h in your c source file first, and you can then include the original libOpto.h in your source file where you would normally place it.

0 Kudos
Message 8 of 15
(5,485 Views)
It says
"
If you do not know the function prototypes included in the DLL, the following link provides suggestions on how to access the prototypes via Windows or Visual C++ tools.


Related Links:
KnowledgeBase 0RIDLPZL: How Can I Find Out the Names of the Functions That Are Exported from My DLL?
 
"
Can i get both function names and all parameters or JUST function names?
 
Another words,
 
function(int x, int y)
OR
function
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 9 of 15
(5,471 Views)
@ mvr:

Thank your for the information!
So this means I could modify the data types in the LibOpto.h to match standard C types and would therefore not have to include  windows.h?
For now I'll just use the include and try if I can get that thing to work...

@ Sheetal:

Take a look at
Display Exported Functions in DLL
tried the VI, but shows you just the function names without parameters...

Regards
0 Kudos
Message 10 of 15
(5,446 Views)