Learn how to run a sample app in C++.
🔹 Create a Visual Studio Project
- Start Visual Studio
On the menu bar, choose File -> New -> Project
On the new window, on the left, expand Installed, expand Templates, expand Other Languages, and then choose Console App (Visual C++)
Specify the Name and Solution Name for your project, then hit OK.
- Note
- Name: This will be the name given to your Namespace/Package/Project. The Project file contains all the information of a project/package/namespace, such as its settings and the .c, .cpp, .h, and .hpp files in the project.
-
Solution Name: This will be the name given to the container for the projects/packages/namespaces and the configurations the projects can build in. A solution is a structure for organizing projects in Visual Studio. The solution maintains the state information for projects in .sln (text-based, shared) and .suo (binary, user-specific solution options) files.
-
For more: visit → Introduction to projects and solutions
- The new project will appear in the Solution Explorer:
- If the SupportSampleApps.cpp should now be displayed and can be accessed in the Solution Explorer under source files.
- Visual Studio will insert a "Hello World!" template into the file.
Choose the F5 key to run the project. A Command Prompt window appears that contains the line:
🔹 Add a Sample App to Your Project
What files do I need to setup my C++ project?
➡️ 32-bit
rsi.h → Primary Header file
RapidCode.lib → [32bit] - Import Library
RapidCode.dll → [32bit] - C++ DLL
➡️ 64-bit
rsi.h → Primary Header file
RapidCode64.lib → [64bit] - Import Library
RapidCode64.dll → [64bit] - C++ DLL
- Set up the project properties.
- Right-click the project in the solution explorer and select "Properties".
- In the drop-down menu in the top left set the Configuration to "All
Configurations"
- In the General section set the Output Directory to the install location of RapidSetup.
In this case C:\RSI\10.x.x
In the C/C++ > General section add the RapidSetup install directory to the Additional Include Directories. Do not overwrite (AdditionalIncludeDirectories).
C:\RSI\10.x.x;%(AdditionalIncludeDirectories)
In the C/C++ > Preprocessor add RSIAPP;
Do not overwrite _<different options>_
- Warning
- Depending on your setup you may want to change the set Precompiled Headers to "Not Using Precompiled Headers"
In the Linker > General section add the RapidSetup install location and the Additional Library Directories to the install location of Rapid Setup.
C:\RSI\10.x.x;%(AdditionalLibraryDirectories)
- In the Linker > General section add
RapidCode.lib
- Add the desired sample app.
- In Solution Explorer (open on View Tab or hit ctrl+alt+L) right click on the Source Files, then click on Add, then click on 'New Item ...'
Change the Name of your file to the name of the Sample App that you want to use and hit Add.
- Note
- For example, if you would like to use our Absolute Motion sample app, then the name of your class will be AbsoluteMotion.cpp.
After you click Add, you will see an empty .cpp file. Paste the desired sample app into the file.
- Note
- The AbsoluteMotion.cpp sample app above can also be found here.
- Add a header file for your sample app.
- Right-click Header Files in the Solution Explorer. Then Add a New Item.
- Name the .h file the same as the sample app you added. In this case "AbsolueMotion.h"
- Add the function for your sample app to the header file. In this case
AbsoluteMotinMain();
- Include the new header file and a call to your sample app function in your main .cpp file.
#include "AbsoluteMotion.h"
AbsoluteMotionMain();
- Add the missing helper functions.
- Create a second header file called "HelperFunctions.h"
Paste the helper functions into this file.
- Note
- The HelperFunctions.h can also be found here.
- Make sure that INtime is running and that your motor/axis has been set up correctly in RapidSetup.
- If the axis has been set up correctly, hit the F5 key to run the project.