Building Code Examples
This page shows how to build the sample code shipped with HOOPS Exchange.
Desktop Platforms
Before you start, you need:
- CMake 3.21 or later, from cmake.org or your package manager.
- A C++ compiler. See Supported Platforms.
- A HOOPS Exchange license. See Installing HOOPS Exchange.
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:
- Open samples/HOOPSExchangeSamples.sln.
- Select the Debug or Release configuration.
- 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.
- To run a sample, right-click it, select Set as Startup Project, then press F5.
Note
Two samples require additional setup:
- .NET Wrapper: Install Microsoft .NET for Visual Studio.
- TranslateToPkParts: See the Parasolid bridge documentation.
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).
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
Open the Xcode project at
samples/ios/PRC2XML/PRC2XML.xcodeproj.
In the Project navigator, select
ts-0000.prc, then right-click and choose Add files to “PRC2XML”….
Build the sample: Product -> Build For -> Running.
Running on the iOS Simulator
Run the sample: Product -> Run.
The iOS Simulator launches. Tap
ts-0000.prcto process the file.
The generated
ts-0000.prc.xmlfile is saved to the app’s Documents folder:~/Library/Developer/CoreSimulator/Devices/<DEVICE_ID>/data/Containers/Data/Application/<APP_ID>/DocumentsOpen the XML file to explore the PRC structure, metadata, and attributes.
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
- Open Android Studio.
- Go to File -> Open and select
samples/android/PRC2XML/. - If prompted about missing SDK components, click the messages to install them (NDK, SDK, etc.).
- Wait for Gradle sync to complete (watch the progress bar at the bottom).
- Build: Build -> Rebuild Project.
- 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.