LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create simple DLL in LabWindows CVI to run from Visual Studio

Hi all,

I am trying to write a simple DLL in CVI that will open a com port and write/read data. This will be used by someone who uses Visual Studio.

 

There is an example using CVI library to write code in Visual Studio which I used and works fine. with the basic code that is in the example.

Search for: "How to Integrate 32-Bit LabWindows/CVI 4.0 Libraries into Microsoft Visual C/C++ or Borland C/C++"

 

And there is an example that has code for CVI project that generated DLL and VS project that used the DLL but I cannot get it to run on VS 2015. Has anyone tried it on VS 2015?

Search for: "Creating a CVI DLL That Contains an UIR File, And Use The DLL in Visual C++"

 

Please give any suggestions.

Thanks,

Dmitry

0 Kudos
Message 1 of 10
(4,516 Views)

Hi Dmitry,

 

How are you opening the com port to write and read data? Are you using API calls into other drivers, such as NI-VISA or NI-Serial to do this?

 

Also, what do you mean you cannot get it to run on VS 2015? Are you seeing errors? If so, could you provide detailed descriptions of the errors that you're seeing?

 

Also, for convenience of others who may be looking at this question, the pages described above are linked here:

 

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

 

Creating a CVI DLL That Contains an UIR File, And Use The DLL in Visual C++

Jorr-El
Systems Engineer
Testeract: Automated Test Specialists
0 Kudos
Message 2 of 10
(4,474 Views)

The request to me was to create DLL with three functions to be used in Visual Studio:

Open Com, Write Com, and Read Com

 

I was able to do it with creating UIR and Object file in CVI2010, attaching all necessary libraries from CVI2010 (extlib/msvc and include folder) and using callback functions to call:

OpenComConfig, ComWrt, and ComRd

 

This is too much visibility of the CVI code. I need to do it seamlessly with DLL and just function calls.

 

Using the DLL example from white paper, just by running the "testDLL.exe" returns MFC42D.DLL is missing. Not sure where to get that from.

 

Opening the example workspace from Visual Studio V6 to V2015 is not recommended by some post that recommended recreating project is better. Otherwise after V2015 done converting old to new project and redirecting locations of CVI libraries (Program Files to Program Files (x86)) the first error after "Start Debug" is "D8016 '/ZI' and '/Gy-' command-line options are incompatible".

 

Not sure why the following is selected to make the right change:

 

Debug Information Format: "Program Database for Edit And Continue (/ZI)"

Enable Function-Level Linking: "No (/Gy-)"

 

I will play with these and in the mean time please advise.

 

Thanks,

Dmitry

0 Kudos
Message 3 of 10
(4,461 Views)

Changing "No (/Gy-)" to "Yes" and Start Debug returned RC1015 cannot open include files:

"res\testDLL.rc2"

"res\testDLL.ico"

"..\..\..\Customers' Issues\dll\testCVI.lib".

 

I guess files were in a different folders before?

First two I can either place in "res" folder or change "testDLL.rc" file to redirect. But I am not sure where the link to the "testCVI.lib" is. I am not sure how the linking works in V2015.

0 Kudos
Message 4 of 10
(4,460 Views)

Pointed to "testCVI.lib" fron the project directory and now getting "unresolved externals".

Will be looking into pointing to the right external directories.

0 Kudos
Message 5 of 10
(4,457 Views)

It cannot find OpenPanel function that was written in CVI, "testCVI.c".

What file passed to VS should contain it?

0 Kudos
Message 6 of 10
(4,456 Views)

Given that I cannot help you on the DLL side which I am not developing in my activity, it's not clear to me if you actually need a DLL with a CVI user interface or only with serial port access. In the latter case, why don't you develop your application directly in Visual Studio, which can actually use the serial port, instead of passing through CVI for that?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 10
(4,445 Views)

There is more to just the three functions that I mentioned.

There are other things happening in my CVI code that the VS developer doesn't want to bother with such as sending specific commands and parsing responses. Hence I need to do everything in the background with a DLL.

0 Kudos
Message 8 of 10
(4,443 Views)

Hi CPST,

 

As far as the missing MFC42D.DLL goes, that seems to be a Microsoft DLL that appears in Windows\System32

 

Here's a Microsoft Forums post about fixing the DLL using regsvr32

https://answers.microsoft.com/en-us/windows/forum/windows_7-windows_programs/mfc-library-files-missi...

 

After doing this, restart your computer and then try running the example .exe from the white paper again. Let us know what happens

Jorr-El
Systems Engineer
Testeract: Automated Test Specialists
0 Kudos
Message 9 of 10
(4,395 Views)

I had no luck finding the MFC libraries and downloading from different websites is prohibited by IT.

 

Is there any way that someone can take the contents of the white paper mentioned in the first post and get it to debug/run in VS2015?

0 Kudos
Message 10 of 10
(4,386 Views)