# Building Code Examples

This guide explains how to build the sample code included in your HOOPS Exchange installation package.

## Quick Start

For desktop platforms (Windows, Linux, macOS with CMake):

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

Executables are placed in `build/bin/`. For platform-specific options, IDE integration, or mobile platforms, see the sections below.

## Desktop Platforms

### Prerequisites

Starting from HOOPS Exchange 2026.3.0, CMake is the recommended build system for all desktop platforms. CMake generates native project files for your preferred IDE or build tool.

You need:

- CMake 3.21 or higher - Download from cmake.org
- A C++ compiler - See Supported Platforms for supported compilers

Tip

New to CMake? Start with the official CMake tutorial.

### Configuring with CMake

CMake generates project files for your chosen build system (Visual Studio, Xcode, Make, Ninja, etc.).

#### Using CMake GUI

1. Open the CMake application.

2. Set the paths:

   - Where is the source code: Select the samples/ folder from your HOOPS Exchange installation.
   - Where to build the binaries: Select an empty folder (e.g., samples/build/).

   Example: HOOPS Exchange extracted to /Users/hoopsy/Downloads/HOOPS_Exchange_2026.2.0/

3. Click Configure and select a generator:

   - Visual Studio 17 2022 for Windows
   - Xcode for macOS
   - Unix Makefiles for Linux/macOS command line

4. Click Generate to create the project files.

5. Click Open Project to launch your IDE, or navigate to the build folder manually.

#### Using the Command Line

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

To specify a generator explicitly:

    cmake -B build -G "Visual Studio 17 2022"   # Windows
    cmake -B build -G "Xcode"                   # macOS
    cmake -B build -G "Unix Makefiles"          # Linux/macOS

#### Next Steps

Your project is now configured. If you selected an IDE generator (Visual Studio, Xcode), you can click the Open Project button in CMake GUI to launch your IDE directly.

Now proceed to build using your preferred method:

- Build with CMake (All Platforms)
- Build with Visual Studio (Windows)
- Build with Make (Linux/macOS)
- Build with Xcode (macOS)

### Build the Samples

#### Build with CMake (All Platforms)

The simplest approach - CMake invokes the appropriate build tool automatically:

    cmake --build build/

For a Release build:

    cmake --build build/ --config Release

Compiled executables are placed in `build/bin/`.

#### Build with Visual Studio (Windows)

Using CMake-generated solution:

1. Open `build/HOOPSExchangeSample.sln` in Visual Studio.

Using pre-built solution (Windows package only):

1. Open `samples/HOOPSExchangeSamples.sln` directly - no CMake required.

Build and run:

1. Select Debug or Release configuration from the toolbar.
2. Build the solution: Build -> Build Solution (Ctrl+Shift+B).
3. To run a sample, right-click it in Solution Explorer, select Set as Startup Project, then press F5.

Compiled executables are placed in the bin/ folder.

Note

Two samples require additional setup:

- .NET Wrapper: Install Microsoft .NET for Visual Studio.
- TranslateToPkParts: See the Parasolid bridge documentation.

#### Build with Make (Linux/macOS)

Using CMake-generated Makefiles:

    cd build/
    make -j$(nproc)      # Linux (parallel build)
    make -j$(sysctl -n hw.ncpu)   # macOS (parallel build)

Compiled executables are placed in `build/bin/`.

Using legacy Makefiles (without CMake):

The Linux and macOS packages include standalone Makefiles:

    cd /path/to/HOOPS_Exchange/samples
    make              # Build all samples
    make DEBUG=1      # Debug build
    make clean        # Clean build artifacts

With legacy Makefiles, executables are placed alongside each sample’s source files.

#### Build with Xcode (macOS)

1. Generate an Xcode project:

       cmake -B build -G Xcode

2. Open the project:

       open build/HOOPSExchangeSample.xcodeproj

3. Select a sample from the scheme dropdown (next to the Stop button).

4. Build: Product -> Build (Cmd+B).

5. Run: 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.

## 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`.

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

3. Build the sample: Product -> Build For -> Running.

#### Running on the iOS Simulator

1. Run the sample: Product -> Run.

2. The iOS Simulator launches. Tap `ts-0000.prc` to process the file.

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.

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.

Conversation saved
HOOPSY BETA

### Hello! I'm HOOPSY

Your multilingual generative AI assistant for documentation. Ask me anything about HOOPS Exchange in your own language, or choose a sample question below to start a conversation:

What is HOOPS Exchange?
What are the latest release notes for HOOPS Exchange?
How do I start evaluating HOOPS Exchange?
How do I write my first sample application?
How can I get assistance?

HOOPSY may store conversations according to OpenAI's policy. Responses may not always be accurate.

HOOPSY is thinking...