03-15-2017 02:38 PM
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
03-16-2017 01:08 PM
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++
03-17-2017 07:00 AM
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
03-17-2017 07:17 AM
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.
03-17-2017 07:29 AM
Pointed to "testCVI.lib" fron the project directory and now getting "unresolved externals".
Will be looking into pointing to the right external directories.
03-17-2017 07:42 AM
It cannot find OpenPanel function that was written in CVI, "testCVI.c".
What file passed to VS should contain it?
03-17-2017 09:12 AM
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?
03-17-2017 09:22 AM
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.
03-20-2017 05:31 PM
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
After doing this, restart your computer and then try running the example .exe from the white paper again. Let us know what happens
03-21-2017 08:05 AM
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?