LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use a Visual C DLL in CVI

I Have a DLL build in Visual C, it includes the source files, .cpp .h
How can I use this DLL in my aplication build in CVI V5.5.

Thanks a lot for the answers.
Image Hosted by ImageShack.us
0 Kudos
Message 1 of 7
(5,660 Views)
First, you have to make sure the functions that are exported from the DLL are in C format, not C++. CVI is not a C++ compiler. You can do this by using extern "C" with your function prototypes that you are exporting. For example:

extern "C" {
void __declspec(dllexport) MyFunction(void);
}

Once the exported functions are "C" style, you just #include the DLL header in your project source code and add the DLL import library (.LIB) to the project. If you don't have an import library, CVI can generate one for you from the header file. Just load the header file in the editor and go to Options->Generate DLL Import Library.

Best Regards,

Chris Matthews
Measurement Studio Support Manager
0 Kudos
Message 2 of 7
(5,659 Views)
I have a Header-file for a DLL. In this Header-file there is the expression
extern "C" {
...
...
}
I have included this H-File in my CVI 5.5 Project.
Problem:
When I try to generate an executable, he reports
Waring: Empty decleration; Found string constant;

Without the extern "C" {... } the project is exectuable, but doesn't working.

Can you help me?
0 Kudos
Message 3 of 7
(5,659 Views)
Hi there.. I have jsut read your question and responses and I am having the same problem. I added the esern "C" {} part to the header file of the DLL, built it in VC++ and then using labwindows cvi, I added the .lib file and the .h file, except I get the same empty declaration problem. Were you ever aboe to fix the problem???
0 Kudos
Message 4 of 7
(5,659 Views)
Try using something like this in your VC header file.

#ifdef __cplusplus
extern "C" {
#endif


// prototypes of functions exported for CVI to call


#ifdef __cplusplus
}
#endif"
0 Kudos
Message 5 of 7
(5,659 Views)
I have the same kind of problem  here. I am getting the following error instead of the errors the people above mentioned. DLL init: Could not find the function or variable ' ??0cbUSBBoard@@IAE@AAUCFGINO@@@Z' in the Dll "cbw32.dl". Make sure that the most recent versions of both the import liabrary and hte DLL are being used  and are in their proper directories.


I have included the .h file and the liabrary file. Please help
0 Kudos
Message 6 of 7
(5,130 Views)
Hi, MCS_T,

Usually this error indicates you're not statically linking to the dll correctly. You need to create a dll import library in CVI to call the dll. If you already have one, maybe it's outdated. After you have an import library, f you still get this error, it would indicate that the function may not exist in the dll.

Song D
Regards,

Song Du
Systems Software
National Instruments R&D
0 Kudos
Message 7 of 7
(5,080 Views)