Web Analytics Made Easy - Statcounter
Skip to content

Building on macOS#

This guide shows how to build a SAMSON Extension on macOS with Qt Creator and CMake.

Use it after you have already installed the SDK and generated an extension workspace. The goal is to configure the root CMake project, build the install target, and run the correct SAMSON executable for Debug or Release.

Requirements#

If you have not installed the SAMSON SDK yet, complete Installation first.

  • Clang, available with Xcode
  • CMake 4.0 or newer
  • Qt 6.10.2
  • Qt Creator or another supported IDE such as Xcode

This page uses Qt Creator as the primary workflow because it aligns well with the generated CMake project.

Configuration of a project in Qt Creator#

Open Qt Creator and choose Open Project... or File > Open File or Project... (Cmd+O).

Select the root CMakeLists.txt in the extension workspace, not the CMakeLists.txt inside one extension folder.

Choose the root CMakeLists.txt

Building for x86_64 on ARM64#

Important

The shipped SAMSON SDK is currently provided for x86_64. On Apple Silicon machines you therefore need to build the extension for x86_64 compatibility.

Change CMakeLists.txt#

If you are on an ARM64 Mac, add the following line near the top of the root CMakeLists.txt, immediately after CMAKE_MINIMUM_REQUIRED:

SET(M1_X86_64 1)

Create a kit for x86_64 on ARM64#

Create or reuse a Qt Creator kit that targets x86_64:

  1. Open Manage Kits...
  2. Clone the auto-detected Qt 6.10.2 macOS kit
  3. Rename it clearly, for example by adding x86_64
  4. Set both the C and C++ compilers to Apple Clang (x86_64)

Kit for x86_64

Configure Project#

  1. Choose the correct kit
  2. Expand Details
  3. Configure both build directories: - Debug: PathToExtensions/build/Debug - Release: PathToExtensions/build/Release
  4. Click Configure Project

Configure Project

If Qt Creator reports errors after the first configure step, continue with the CMake variables below.

Build Settings#

CMake configuration#

Add the variables expected by the generated workspace:

  1. Add a string variable named SAMSON_SDK_PATH and set it to: $HOME/OneAngstrom/SAMSON-Sdks/11.0.0
  2. Add a boolean variable named DEBUG. - Set it to ON for the Debug configuration - Leave it OFF for the Release configuration
  3. Click Re-configure with Initial Parameters

CMake configuration

Build Steps#

To ensure the extension is installed into SAMSON automatically:

  1. Scroll to Build Steps
  2. Expand the details
  3. Enable the install option

Build steps: add the install option

Build#

Open the Edit view to inspect the project tree, then build with Cmd+B or Build > Build Project "SAMSON-Elements".

Build project

Checkpoint:

  • the project configures successfully
  • the build succeeds
  • the install step copies the extension into the expected SAMSON location

Note

Building the install target automatically builds the project if needed.

Run Settings#

As on other platforms, the SAMSON executable must match the build configuration:

  • Debug extension builds run against the SAMSON Debug executable from the SDK
  • Release extension builds run against the normal SAMSON application installation

In Projects mode (Cmd+5), create one run configuration for each build configuration and set the executable:

$HOME/OneAngstrom/SAMSON-Sdks/11.0.0/SAMSON-Debug/Binaries/SAMSON-Core-Console

$HOME/Applications/SAMSON.app/11.0.0/Binaries/SAMSON-Core-Console

Important

Replace $HOME with the actual path to your user directory.

Then add the environment variables needed for Qt frameworks and SAMSON libraries:

  • DYLD_LIBRARY_PATH=$HOME/OneAngstrom/SAMSON-Sdks/11.0.0/SAMSON-Debug/Binaries
  • DYLD_FRAMEWORK_PATH=$HOME/Qt/6.10.2/macos/lib:$HOME/Applications/SAMSON.app/11.0.0/Binaries
  • DYLD_LIBRARY_PATH=$HOME/OneAngstrom/SAMSON/11.0.0/SAMSON/Binaries
  • DYLD_FRAMEWORK_PATH=$HOME/Qt/6.10.2/macos/lib:$HOME/Applications/SAMSON.app/11.0.0/Binaries

Run configuration: environment

Run#

Once the run settings are configured:

  1. build with Cmd+B
  2. run with Cmd+R
  3. verify that SAMSON starts and the extension is loaded

Tip

If you pair a Debug build with a Debug run configuration, you can debug the extension directly from Qt Creator.

Adding files to a SAMSON Extension#

When you add or remove source files, classes, or resources, regenerate the project by:

  • rerunning CMake, or
  • making a small change to the relevant CMakeLists.txt file and letting Qt Creator reconfigure automatically on the next build

Adding new SAMSON Extensions to the project#

If you generate new extensions in the same workspace, the Extension Generator updates the root CMakeLists.txt through ADD_SUBDIRECTORY. The next CMake reconfiguration should add the new extension targets automatically.

Troubleshooting#

  • On Apple Silicon, confirm that you are using an x86_64 kit when targeting the shipped SDK.
  • If SAMSON starts but the extension does not load, verify that the run configuration matches the build configuration.
  • If Qt Creator reports stale targets, trigger a fresh CMake reconfiguration.

If you have questions or issues, use the SAMSON Connect Forum or contact us.

Next steps#