How Do I Move the CVI PID Toolkit to Visual C++ ?
Primary Software: LabWindows/CVI Add-ons>>PID Control Toolset
Primary Software Version: 1.1
Primary Software Fixed Version: N/A
Secondary Software: N/A
Problem: How do I move the CVI PID toolkit to Visual C++ ?
Solution: With the CVI PID toolkit customers will get the pid.c file (along with the pid.fp and the pid.h and a bunch of other files).
So you can move and use the toolkit in VC++.
To do this:
- Use the MFC appwizard to create a new Dialog based project.
(Launch VC ++ , choose File-->New-->Project Tab-->MFC AppWizard -). Choose a Dialog based application. Follow the wizard steps.
- Now go to Project-->Add To Project--> Files and add the pid.c file (optionally the pid.h though you don't need to ).
- In your C++ source code you will need to #include "pid.h"
The pid.c uses two CVI libraries , utility.lib and the ansi_c.lib. So you will need to include the cvisupp.lib and cvirt.lib to the VC++ project.
- Add the libraries using the same procedure in step (2) except that you add a library as opposed to a .c or .h file. the libraries can be found in the cvi\extlib folder.
Do NOT use the CVI Ansic library in VC++. Use the native compilers ANSI C libraries.
- Hence , in pid.c , remove the " #include <ansi_c.h> " definition.
- You need to add the "pid.h" file to the include paths in VC++. ( Tools-->Options-->Directory(tab) add the directory with the pid.h)
- If you now try to Execute your project ( hitting the " ! " icon) you will get the following error:
fatal error C1010: unexpected end of file while looking for precompiled header directive
This error is due to a Microsoft setting. We are not using precompiled headers in our program.
- To get rid of the precompiled headers, go to Project-->Settings -->C/C++(tab)-->Category (choose precompiled headers)-->Not using precompiled headers.
- Add a function to the C++ code ( I create a new button and a method for it). Say you call the setpoint function.
- Try running again...you will get the error
unresolved external symbol "void __stdcall pid_setpoint(int,double)" (?pid_setpoint@@YGXHN@Z) (I called the setpoint function in my code) This is because of name mangling.
Add:
#ifdef __cplusplus
extern "C" {
#endif
to the start of the header file and
#ifdef __cplusplus
}
#endif
at the end.
You should now be able to compile without any additional problems
Related Links:
Attachments:
Report Date: 10/20/1999
Last Updated: 05/18/2005
Document ID: 1QJG8SPR