A modular C++ project using Meson build system, demonstrating cross-platform dynamic libraries and shared headers.
This project demonstrates how to organize and build modular C++ libraries and applications using the Meson build system. It supports both Windows and Linux, with shared headers and cross-platform symbol export macros.
apps/
├──hello/
│ └── hello.cpp
│ └── meson.build
libs/
├── common/
│ └── include/common/meson_hello_api.h
│ └── meson.build
├── greetings/
│ └── include/greetings/greetings.h
│ └── src/greetings.cpp
│ └── meson.build
├── salutations/ │
│ └── include/salutations/salutations.h
│ └── src/salutations.cpp
│ └── meson.build
meson.build
.gitignore- Visual Studio 2022
- Meson and Ninja
- Git (optional, for cloning)
- Open a Developer Command Prompt for VS.
- Install Meson and Ninja if not already installed:
pip install meson ninja- Configure the build directory:
Notes:--prefixsets theinstalldirectory. <install directory> must be an absolute path- Run
meson --help setupfor additional options
meson setup <build directory> --backend=vs --prefix <install directory>
example: meson setup build/build-win --prefix c:/git/meson-test/install/bin- Build the project:
meson compile -C <build directory>
example: meson compile -C build/build-win- Optionally, run all tests to verify the build:
meson test -C <build directory>
example: meson test -C build/build-win- Install the project:
meson install -C <build directory>
example: meson install -C build/build-winTo run the built applications, ensure the install directory is in your PATH, or use the full path to the executables. For example:
<install directory>\hello.exe
example: install\bin\hello.exe- Install the required tools and libraries. For example, on Ubuntu:
sudo apt install build-essential git- Clone the repository (if you haven't already):
git clone https://github.com/username/meson-test.git- Navigate to the project directory:
cd meson-test- Configure the build directory:
meson setup builddir --prefix=/usr/local- Build the project:
meson compile -C builddir- Optionally, run all tests to verify the build: