APIs, concepts, guides, and more
Run a sample app in C++ (pre v10.5.3)

Learn how to run a sample app in C++.

🔹 Create a Visual Studio Project

  1. Start Visual Studio
  2. On the menu bar, choose File -> New -> Project

    Image

  3. On the new window, on the left, expand Installed, expand Templates, expand Other Languages, and then choose Console App (Visual C++)

    Image

  4. Specify the Name and Solution Name for your project, then hit OK.

    Image

    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
    1. The new project will appear in the Solution Explorer:

    Image

  5. If the SupportSampleApps.cpp should now be displayed and can be accessed in the Solution Explorer under source files.
  6. Visual Studio will insert a "Hello World!" template into the file.
  7. Choose the F5 key to run the project. A Command Prompt window appears that contains the line:

    Hello World!

    Image

🔹 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

  1. Set up the project properties.
    1. Right-click the project in the solution explorer and select "Properties". Image
    2. In the drop-down menu in the top left set the Configuration to "All Configurations" Image
    3. In the General section set the Output Directory to the install location of RapidSetup.
      In this case C:\RSI\10.x.x Image
    4. 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)

      Image

    5. In the C/C++ > Preprocessor add RSIAPP; Do not overwrite _<different options>_

      Image

      Warning
      Depending on your setup you may want to change the set Precompiled Headers to "Not Using Precompiled Headers"
    6. 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)

      Image

    7. In the Linker > General section add RapidCode.lib Image
  2. Add the desired sample app.
    1. 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 ...' Image
    2. Change the Name of your file to the name of the Sample App that you want to use and hit Add. Image

      Note
      For example, if you would like to use our Absolute Motion sample app, then the name of your class will be AbsoluteMotion.cpp.
    3. 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.
  3. Add a header file for your sample app.
    1. Right-click Header Files in the Solution Explorer. Then Add a New Item.
      Image
    2. Name the .h file the same as the sample app you added. In this case "AbsolueMotion.h"
    3. Add the function for your sample app to the header file. In this case AbsoluteMotinMain();
    4. Include the new header file and a call to your sample app function in your main .cpp file.
      #include "AbsoluteMotion.h"
      AbsoluteMotionMain();
      Image
  4. Add the missing helper functions.
    1. Create a second header file called "HelperFunctions.h"
    2. Paste the helper functions into this file.

      Note
      The HelperFunctions.h can also be found here.
  5. Make sure that INtime is running and that your motor/axis has been set up correctly in RapidSetup.
  6. If the axis has been set up correctly, hit the F5 key to run the project.