Vxworks5.5 can only create a static library (. a). After vxworks6.0, the dynamic link library (. So) function is added to facilitate multi-process use of dynamic libraries. This article inherits the consistent style of Win32 and Linux programming, uses a simple dynamic library generation step, and writes the RTP program for testing. This gives you a preliminary understanding of the powerful functions of vxworks6.6, at the same time, we also noticed that vxworks6.6 is much more complicated than vxworks5.5. I believe that with these simple programming knowledge points, you have mastered the vxworks6.6 debugging skills, so that we don't have to explore the darkness during the debugging process. This article uses graphs to describe the operation process.
In Versions later than vxworks6.0, real-time process (RTP) with full protection has been introduced. For the first time, it perfectly resolves the conflict between kernel protection and real-time and certainty. You can dynamically create or delete RTP Real-time protection processes as needed or only run some programs in RTP Real-time protection processes. RTP real-time processes can dynamically load and run external programs at any time. Every RTP process is completely independent. Any errors that occur in the RTP process are restricted within the RTP process. All resources are automatically released when the real-time RTP process is deleted. Unlike other multi-process operating systems, the real-time RTP process of VxWorks has completely static certainty, providing protection functions while providing the highest real-time response certainty and speed, it also provides complete error detection and report storage functions. The dynamic link library and shared data zone functions are also provided. The real-time RTP protection process, together with the original high-performance real-time tasks of vworks, constitutes a super device platform with both protection and real-time performance.
Dynamic library generation
1. Select the project work path
2. normally open the initial interface
Generally, a similar interface appears in the lower left corner, indicating that your vxworks6.6 system is installed normally. It should be noted that tornado2.2 installed in the system will conflict with workbench3.0. It is best to uninstall tornado2.2, and Windows does not support the installation of both.
3. Create a dynamic library project
4. Dynamic library name
5. Compile and select
Here we chose the Diab tool for compilation. The GNU compilation tool has some problems in debugging the class in C ++. I did not study the specific cause.
6. By default, click Finish.
7. Add the INC and SRC folders.
A,INC includes demo. h and stdafx. h;
B,SRC contains demo. cpp and stdafx. cpp.
stdafx.h// stdafx.h : include file for standard system include files,// or project specific include files that are used frequently, but// are changed infrequently//#if !defined(AFX_STDAFX_H__E5CE9468_AAF9_46A6_979B_9C125F6E9D00__INCLUDED_)#define AFX_STDAFX_H__E5CE9468_AAF9_46A6_979B_9C125F6E9D00__INCLUDED_#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000#define WIN32_LEAN_AND_MEAN// Exclude rarely-used stuff from Windows headers#include <stdio.h>// TODO: reference additional headers your program requires here//{{AFX_INSERT_LOCATION}}// Microsoft Visual C++ will insert additional declarations immediately before the // previous line.#endif // !defined(AFX_STDAFX_H__E5CE9468_AAF9_46A6_979B_9C125F6E9D00__INCLUDED_)stdafx.cpp// stdafx.cpp : source file that includes just the standard includes//libdemo.pch will be the pre-compiled header//stdafx.obj will contain the pre-compiled type information#include "stdafx.h"// TODO: reference any additional headers you need in STDAFX.H// and not in this filedemo.h#ifndef _DEMO_H_#define _DEMO_H_// The following ifdef block is the standard way of creating macros which make exporting // from a DLL simpler. All files within this DLL are compiled with the AE_DEMO_EXPORTS// symbol defined on the command line. this symbol should not be defined on any project// that uses this DLL. This way any other project whose source files include this file see // AE_DEMO_ENTRY functions as being imported from a DLL, wheras this DLL sees symbols// defined with this macro as being exported.#ifdef WIN32#ifdef AE_DEMO_EXPORTS#define AE_DEMO_ENTRY __declspec(dllexport)#else#define AE_DEMO_ENTRY __declspec(dllimport)#endif#else#define AE_DEMO_ENTRY#endif// This class is exported from the libdemo.dllclass AE_DEMO_ENTRY CTest {public:CTest();virtual ~CTest();public:int Add(int a, int b);protected:intm_nCount;};extern AE_DEMO_ENTRY int nTest;AE_DEMO_ENTRY int fnTest();#endif // _DEMO_H_demo.cpp#include "stdafx.h"#include "demo.h"// This is an example of an exported variableAE_DEMO_ENTRY int nTest = 0x64;// This is an example of an exported function.AE_DEMO_ENTRY int fnTest(){return 64;}// This is the constructor of a class that has been exported.// see demo.h for the class definitionCTest::CTest(){ }CTest::~CTest(){ }int CTest::Add(int a, int b){return (a + b);}
8. Add the INC path
9. Refresh the project
, Right click to refresh the project, INC and SRC to add it to the project.
10. compile the project
Select "build project" from the shortcut menu to complete compilation, and copy the compiled dynamic library libdemo. So
$ (Fephome)/bin for later use.
Note: The fephome environment compilation = C:/opensuse3000/FEP contains a backslash.
Dynamic library call
Calling vxworks6.6 is troublesome and requires many configurations.
1. Create a project
2. Compile and select
3. completed by default
4. Compile attributes
5. Compile attributes-linker
6. Select create a dynamic executable.
7. Set libpath and libs
8. inclusion path
$ (Fephome)/code/include is included here, because libdemo. h needs to be put here, which is an implicit call method.
After the preceding settings are complete, the compilation method is relatively simple. Copy the compiled dynamic library testdemo. vxe to $ (fephome)/bin for later use.
9. Start Simulation
10. debugging
Because the dynamic link library is used for RTP, we can only choose debug RTP on target to run on the target machine.
11. Set the running program path
12. Run debug
After the above debug button is executed, the following screen will appear.
13. One-Step F6 execution
Debugging can be performed in one step by pressing F6. This function button is also available on the toolbar in the upper right corner. Select ta B in the console in the middle. The output result is displayed.
14. The executed Simulator
Shell call
1. first look at the virtual path of the simulator.
2. Run testdemo. vxe in the simulator.