# How to Link Against the MulleObjC-startup Library in Your Project

> Effortlessly link against the MulleObjC-startup library in your project. Discover simple dependency management with mulle-sde or manual CMake integration for seamless setup.

- Repository: [mulle-objc/mulleobjc-startup](https://github.com/mulle-objc/mulleobjc-startup)
- Tags: how-to-guide
- Published: 2026-03-07

---

**To link against the MulleObjC-startup library, either use `mulle-sde add github:mulle-objc/MulleObjC-startup` for automatic dependency management, or manually configure CMake to include the library subdirectory and link the `MulleObjC-startup` target to your executable.**

The `mulle-objc/mulleobjc-startup` repository provides a static library that supplies the essential `__register_mulle_objc_universe` entry point and automatically pulls in required runtime dependencies including `mulle-atinit` and `mulle-atexit`. Linking this library is mandatory for any executable that needs to bootstrap the Mulle Objective-C runtime. This guide covers both automated and manual integration methods.

## Using mulle‑sde to Link MulleObjC‑startup

The **mulle‑sde** build tool offers the simplest way to integrate the library, automatically handling include paths, compiler flags, and link targets.

### Adding the Dependency

Run the following command in your project root to fetch and link the library:

```bash
mulle-sde add github:mulle-objc/MulleObjC-startup

```

This command retrieves the source code, updates your build configuration, and inserts the `-lMulleObjC-startup` link flag. After adding the dependency, build and run your project normally:

```bash
mulle-sde run

```

The tool ensures that the static library and its transitive dependencies are correctly linked without manual CMake editing.

## Manual CMake Integration

For projects requiring explicit control over the build system, you can manually add the library as a CMake subdirectory.

### Adding the Library Subdirectory

First, clone the repository or add it as a git submodule, then reference it in your [`CMakeLists.txt`](https://github.com/mulle-objc/mulleobjc-startup/blob/main/CMakeLists.txt):

```cmake
cmake_minimum_required(VERSION 3.13)
project(MyApp LANGUAGES C)

# Add the startup library source tree

add_subdirectory(path/to/MulleObjC-startup)

```

The [`CMakeLists.txt`](https://github.com/mulle-objc/mulleobjc-startup/blob/main/CMakeLists.txt) in the library root defines the static target using the `Library` macro provided in `cmake/share/Library.cmake`.

### Linking the Target

Connect the startup library to your executable and ensure headers are discoverable:

```cmake
add_executable(${PROJECT_NAME} main.c)

# Link the static startup library

target_link_libraries(${PROJECT_NAME} PUBLIC MulleObjC-startup)

# Include the public headers

target_include_directories(${PROJECT_NAME}
    PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/path/to/MulleObjC-startup/include
)

```

This configuration imports the implementation from `src/MulleObjC-startup.m`, which contains the `__register_mulle_objc_universe` function that bootstraps the Objective-C universe.

## Required Headers and Implementation Details

Regardless of the integration method, source files that interact with the startup routine must import the public header:

```c
#import <MulleObjC-startup/MulleObjC-startup.h>

```

The library exports the `__register_mulle_objc_universe` symbol defined in `src/MulleObjC-startup.m`, which initializes the runtime environment. The build definition in [`CMakeLists.txt`](https://github.com/mulle-objc/mulleobjc-startup/blob/main/CMakeLists.txt) uses `cmake/share/Library.cmake` to create the compile and link targets properly.

When using **mulle‑sde**, these includes are configured automatically. In manual setups, verify that `path/to/MulleObjC-startup/include` is in your compiler's search path.

## Summary

- **MulleObjC-startup** is a static library that provides the `__register_mulle_objc_universe` entry point required to bootstrap the Mulle Objective-C runtime.
- Use `mulle-sde add github:mulle-objc/MulleObjC-startup` for automatic linking and header configuration.
- For manual CMake integration, use `add_subdirectory` followed by `target_link_libraries(your_exe PUBLIC MulleObjC-startup)`.
- Include `<MulleObjC-startup/MulleObjC-startup.h>` in source files that need access to the startup routine.
- The implementation resides in `src/MulleObjC-startup.m`, with build logic defined in the root [`CMakeLists.txt`](https://github.com/mulle-objc/mulleobjc-startup/blob/main/CMakeLists.txt) and `cmake/share/Library.cmake`.

## Frequently Asked Questions

### What is the purpose of the MulleObjC-startup library?

The library provides the `__register_mulle_objc_universe` function that initializes the Objective-C runtime universe. It also links against `mulle-atinit` and `mulle-atexit` to handle constructor and destructor priorities, ensuring the runtime is ready before your application code executes.

### Can I use MulleObjC-startup with build systems other than CMake?

While the repository is optimized for CMake and **mulle‑sde**, you can adapt the build logic for other systems. The critical requirement is compiling `src/MulleObjC-startup.m` and linking the resulting static library with your executable, then ensuring the header path `include/` is available to the compiler.

### Why does my executable fail to link without MulleObjC-startup?

The Mulle Objective-C runtime requires a specific entry point to register the universe before `main()` executes. Without linking against `MulleObjC-startup`, the `__register_mulle_objc_universe` symbol remains undefined, causing linker errors or runtime crashes when attempting to send Objective-C messages.

### Where are the public headers located in the repository?

The public interface is located at [`include/MulleObjC-startup/MulleObjC-startup.h`](https://github.com/mulle-objc/mulleobjc-startup/blob/main/include/MulleObjC-startup/MulleObjC-startup.h) in the source tree. When using **mulle‑sde**, this path is added to your include search paths automatically. For manual CMake setups, you must explicitly add the `include` directory to your target's include directories.