Compiling and Running - PIONEER-Experiment/zmq_publisher GitHub Wiki

Publisher Build and Run Guide

The publisher application is a top-level executable built on the analysis_pipeline framework. It publishes MIDAS events over ZeroMQ for downstream consumers.


Prerequisites

System Packages

You must have the following installed on your system:

  • C++17 toolchain (GCC ≥ 9, Clang ≥ 10, or MSVC ≥ 2019)

  • CMake ≥ 3.18

  • Git

  • ROOT (with Core, RIO, Tree, Hist, TreePlayer components discoverable by find_package(ROOT)).

  • ZLIB

  • Threads (system default)

  • ZeroMQ library (libzmq)

    • Debian/Ubuntu:

      sudo apt update
      sudo apt install libzmq3-dev
    • Fedora/RHEL:

      sudo dnf install zeromq-devel

Cloning the Repository

Clone the official repository from GitHub:

git clone https://github.com/PIONEER-Experiment/zmq_publisher.git
cd zmq_publisher

This will give you the full source tree, including scripts for building and running.


Environment Setup

Before building, ensure MIDASSYS is set. In principle, this is the only environment variable you need set. You can either export it manually:

export MIDASSYS=/path/to/midas/install

or let the detection script try to configure it (this doesn't always work well):

cd scripts/environment
./detect_environment.sh
source .env
cd ../..

The script will:

  • Search for a MIDAS installation and set MIDASSYS.

  • Search for an exptab file and set MIDAS_EXPTAB and MIDAS_EXPT_NAME.

  • List candidate install paths for ZeroMQ and cppzmq, but will not set them automatically. If needed, add to .env manually. This should only be needed for local installs of ZeroMQ.

    export ZEROMQ_ROOT=/path/to/zeromq
    export CPPZMQ_ROOT=/path/to/cppzmq

Then source the .env file before running ./scripts/build.sh:

source scripts/environment/.env

Dependency Management

All project dependencies are managed automatically via CPM.cmake. This includes:

  • cppzmq (header-only)
  • oneTBB
  • analysis_pipeline_core
  • analysis_pipeline
  • midas_receiver
  • unpacker_data_products_core
  • midas_event_unpacker_plugin

You do not need to install these manually — CPM fetches and builds them during configuration.


Building

From the repository root:

Clean Build

./scripts/build.sh --overwrite

Incremental Build

./scripts/build.sh

The script handles:

  1. Creating build/
  2. Running CMake
  3. Running make -jN (with -j defaulting to all processors)

Output:

  • Executables: build/bin/
  • Libraries: build/lib/

Running

Use the provided run.sh wrapper:

./scripts/run.sh [OPTIONS] [-- <args>]

Options

  • -h, --help – Show help
  • -d, --debug – Run under gdb
  • -v, --valgrind – Run under valgrind
  • --preload <libs> – Comma-separated list of libraries to LD_PRELOAD

Examples

Run normally:

./scripts/run.sh -- -c config.json

Run with gdb:

./scripts/run.sh --debug -- -c config.json

Run with valgrind:

./scripts/run.sh --valgrind -- -c config.json

Screened Execution

For long-running sessions, you can run publisher inside a detached screen:

./screen_publisher [--no-log]

Stop it with:

./stop_publisher_screen.sh

Troubleshooting

  • MIDASSYS not set Ensure you have installed MIDAS and exported the path.

    export MIDASSYS=/path/to/midas
  • ZeroMQ not found Install libzmq from your system package manager. If installed to a custom location, set:

    export ZEROMQ_ROOT=/path/to/zeromq
  • cppzmq not found Normally fetched automatically by CPM. If you want to use a system-installed version:

    export CPPZMQ_ROOT=/path/to/cppzmq

Notes

  • This project is an application, not a library — there is no install() step.
  • Dependencies are pinned via cmake/CPMConfig.cmake.
  • No manual cloning of submodules is required.

⚠️ **GitHub.com Fallback** ⚠️