Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this first example, you will go step-by-step through the entire process of setting up your build folder using CMake, opening and viewing the C++ code in Visual Studio, compiling your first executable, running it and viewing the results in OpenSim.  The topics covered in this section include:

...

Compiling and running the example

If your CMake is older than 3.8, then you must open the Visual Studio "solution" or Xcode project manually. In File Explorer or Finder, navigate to the build directory you just created using CMake, e.g., <WorkSpace>/ExampleMain/build. Double-click on OpenSimTugOfWar.sln (Windows) or OpenSimTugOfWar.xcodeproj (Mac).

Windows: Visual Studio

  1. The Solution Configuration (drop-down in the toolbar) should be Release. If you choose Debug, your code will not run unless you built the OpenSim API in Debug (the OpenSim API that comes with the GUI is built in Release). You can also choose RelWithDebInfo (Release with debug info), which will allow you to debug your code.
  2. Open the TugOfWar1_CreateModel.cpp file, by browsing the libraries in your Solution Explorer.
  3. Compile the .cpp file(s): right-click on ALL_BUILD and choose Build from the drop-down menu. In the bottom Output window you can see whether or not your file compiled correctly.
  4. Run the program you just created, using one of two methods:
    1. In File Explorer, navigate to the build directory and then to the Release directory. Open the executable that you just created: exampleMain.exe
    2. Run the program from Visual Studio. In the Solution Explorer, right-click exampleMain, and select Set as StartUp Project. Then open the DEBUG menu and select Start Without Debugging. If you used RelWithDebInfo instead of Release and if you select Start With Debugging (from the DEBUG menu), you can pause the program at any line you want by adding a breakpoint. This you can do by clicking anywhere in the left grey column.
  5. You should see a console that says "OpenSim example completed successfully."
  6. If you had issues running the program, it is likely because C:\OpenSim 4.x\bin is not on your Windows PATH; see the previous page for more information.

...

Panel
borderColorgray
bgColorwhite
borderWidth5
borderStylesolid

Next:  /wiki/spaces/OpenSim/pages/5308429453084236

Previous: Prerequisites

Home: Scripting and Development | Developer's Guide