Building Code Examples

This page shows how to build the sample code shipped with HOOPS Exchange.

Desktop Platforms

Before you start, you need:

You don’t need to write any CMake code or set environment variables. The samples find HOOPS Exchange in the package on their own.

Build All Samples

Run these commands from the samples/ folder of your HOOPS Exchange package:

cd /path/to/HOOPS_Exchange/samples
cmake -B build
cmake --build build --parallel

Executables are placed in build/bin/. On Windows, they go into a Debug/ or Release/ subfolder.

Build a Single Sample

Each sample is a build target named after its folder. For instance, to build only hello_world/ImportExport:

cmake -B build
cmake --build build --target ImportExport

You only need to run cmake -B build once. After that, build any sample with cmake --build build --target <SampleName>. To build several samples at once, list them after --target.

See Example Codes for the list of samples.

Run a Sample

./build/bin/ImportExport                  # Linux, macOS
build\bin\Debug\ImportExport.exe          # Windows

The location of the HOOPS Exchange binaries and of the sample data is compiled into each sample, so you can run it from build/bin/ without any further setup.

Keep Using Make (Linux, macOS)

On Linux and macOS, cmake -B build generates regular Makefiles by default. Run it once, and then build with make as usual:

cmake -B build                   # once
make -C build -j8                # all samples
make -C build ImportExport       # a single sample

Note

The standalone Makefiles previously shipped in the samples folder were removed in HOOPS Exchange 2026.6.0.

Build with Visual Studio (Windows)

The Windows package includes a ready-made solution, so CMake is not needed:

  1. Open samples/HOOPSExchangeSamples.sln.
  2. Select the Debug or Release configuration.
  3. To build every sample, select Build -> Build Solution (Ctrl+Shift+B). To build a single sample, right-click it in Solution Explorer and select Build.
  4. To run a sample, right-click it, select Set as Startup Project, then press F5.

Note

Two samples require additional setup:

Build with Xcode (macOS)

Generate an Xcode project and open it:

cmake -B build -G Xcode
open build/HOOPSExchangeSample.xcodeproj

Select a sample in the scheme dropdown, then select Product -> Run (Cmd+R).

../_images/build_xcode.png

Note

On first run, macOS may block the HOOPS Exchange library. Go to System Settings -> Privacy & Security and click Allow Anyway.

Build from Another IDE

Visual Studio (File -> Open -> Folder), Visual Studio Code with the CMake Tools extension, CLion, and Qt Creator open CMake projects directly. Open the samples/ folder and select a sample to build and run it from the IDE.

Build Options

Add any of these options to the cmake -B build command, for instance cmake -B build -DHOOPS_BUILD_PUBLISH=OFF:

Option Effect
-DCMAKE_BUILD_TYPE=Release Builds in release mode on Linux and macOS. On Windows, and with Xcode, add --config Release to the cmake --build command instead.
-DHOOPS_BUILD_PUBLISH=OFF Skips the publishing samples.
-DHOOPS_EXCHANGE_DISABLE_SAMPLES_VIEWER=ON Skips the Viewer and MeshViewer samples. Use it on Linux if OpenGL or GLUT development packages are missing.
-DPARASOLID_INSTALL_DIR=<path> Builds TranslateToPkParts, which is skipped when Parasolid is not found.
-DA3DLIBS_ROOT=<path> Points to your HOOPS Exchange package if you moved the samples/ folder out of it.

Mobile Platforms

Mobile platforms have limited CAD format support and fewer samples compared to desktop.

iOS

Supported formats:

  • Import: SolidWorks, IFC, IGES, JT, Parasolid, PDF, PRC, STEP, STEPXML, U3D
  • Export: IGES, Parasolid, STEP

Available samples:

  • PRC2XML: Loads a CAD file and dumps the model tree, metadata, and attributes to XML.
  • IOSWriter: Loads a CAD file and converts it to another format.

Package contents: bin/, includes/, samples/, documentation/

Build the iOS Samples

  1. Open the Xcode project at samples/ios/PRC2XML/PRC2XML.xcodeproj.

    ../_images/prc2xml-ios.png
  2. In the Project navigator, select ts-0000.prc, then right-click and choose Add files to “PRC2XML”….

    ../_images/add-files-prc2xml-ios.png
  3. Build the sample: Product -> Build For -> Running.

    ../_images/build-prc2xml-ios.png

Running on the iOS Simulator

  1. Run the sample: Product -> Run.

    ../_images/run-prc2xml-ios.png
  2. The iOS Simulator launches. Tap ts-0000.prc to process the file.

    ../_images/simulator-ios.png
  3. The generated ts-0000.prc.xml file is saved to the app’s Documents folder:

    ~/Library/Developer/CoreSimulator/Devices/<DEVICE_ID>/data/Containers/Data/Application/<APP_ID>/Documents

  4. Open the XML file to explore the PRC structure, metadata, and attributes.

    ../_images/xml-ios.png

Note

The iOS samples are Swift applications that use C++ bridging headers to call HOOPS Exchange APIs.

Android

Available samples:

  • PRC2XML: Loads a CAD file and dumps the model tree structure to XML.

Build the Android Sample

  1. Open Android Studio.
  2. Go to File -> Open and select samples/android/PRC2XML/.
  3. If prompted about missing SDK components, click the messages to install them (NDK, SDK, etc.).
  4. Wait for Gradle sync to complete (watch the progress bar at the bottom).
  5. Build: Build -> Rebuild Project.
  6. Run: Run -> Run ‘app’ (Shift+F10) and select your device or emulator.

Warning

Path length limitation (Windows): If you see errors about paths exceeding 240 characters, move the project closer to the drive root (e.g., C:\dev\PRC2XML).

Note

The Android sample uses Java with JNI to call HOOPS Exchange C++ APIs. Native code is built via CMake through the Android NDK.