LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

database toolkit add on - using in a dll/lib file

When using the database functions (for example, DBError) in a dll file called from MS Visual Studio, I get linking errors because the functions are not found.  I copied the header file for the functions into the project that is compiled to a dll, but this did not help.

 

What options do I need to set in the project properties?  Or how do I fix this?

 

 

Thanks!

0 Kudos
Message 1 of 6
(3,918 Views)

In general, you need to compile the client code (the code calling the dll functions) using the header file that defines the functions in the DLL, and you have to link to the DLL using the .lib file that contains the "glue" code that invokes the dll function, fixes up paramter and return types, etc.)  The header file and .lib file are generated when you create the DLL.  It sounds like you're using a DLL created in CVI?  When you set the module type as DLL, CVI generates the .h and .lib files mentioned.  You also have to make sure the same calling convention is used, usually stdcall.

 

Of course, there are exceptions to all of this.

 

But, the most common way of invoking a dll function requires the above compile / link steps.

 

There's a white paper / tutorial on this site on how to build and use DLLs.

 

Menchar

0 Kudos
Message 2 of 6
(3,910 Views)

I added cvi_db.h to the project that is compiled to a dll, and modified the function declaration to include the _declspecl (I'm probably not spelling this correctly) terminology.  This did not help.

 

The functions I created are able to be accessed via the dll.

 

The functions provided by Labwindows, such as DBErrorMessage, are causing the problem.

 

How do I provide access to Labwindows functions through a dll?  Specifically those in the 'database connectivity toolkit' ?

 

 

Thanks!

0 Kudos
Message 3 of 6
(3,865 Views)

Hi coolGal,

 

Here are two documents which walk through two different approaches for accessing CVI functions from Visual Studio:

 

DevZone: How to Integrate 32-Bit LabWindows/CVI 4.0 Libraries into Microsoft Visual C/C++ or Borland...

KnowledgeBase: Integrating LabWindows/CVI with Microsoft Visual C++

 

Best Regards,

 

John M

National Instruments
Applications Engineer
0 Kudos
Message 4 of 6
(3,839 Views)

John,

 

Thanks for the links . . . We did indeed use the method of "The LabWindows/CVI Project Wizard creates a Visual C++ project that uses the LabWindows/CVI run-time libraries"   and then also "Option 1. Define the user interface callback functions in the external third-party compiler"

 

This works great.

 

Until I added the 'database connectivity toolkit' and tried to access things like DBErrorMessage.  This does not link in MS Visual Studio. 

 

What do I modify to get the MS Visual Studio project to include the database connectivity toolkit?  What files actually make up this 'toolkit'?

 

 

 

 

0 Kudos
Message 5 of 6
(3,835 Views)

Hi coolGal,

 

Please try the following:

 

  • Open Visual Studio and create a New Project
  • In the New Project Window, select Visual C++ » LabWindows/CVI » LabWindows/CVI Project, then click Next
  • In the Options window, leave the defauls selected (EXE, Cteate a started C++ file, and Full run-time engine), then click Finish
  • Open the cpp file that was created and add #include <cvi_db.h> underneath the existing #include <cvirte.h>
  • In the WinMain function, add char *myMessage = DBErrorMessage(); just above the call to CloseCVIRTE();
  • Select Build » Build Solution

For me, this builds and links successfully with CVI 2009 and Visual Studio 2008. What versions of CVI, Visual Studio, and the SQL Toolkit are you using? Also, what operating system are you on?

 

Best,

 

John M

National Instruments
Applications Engineer
0 Kudos
Message 6 of 6
(3,805 Views)