# Where Is the Main Source File for MulleObjC-startup Located?

> Discover the main source file for MulleObjC-startup at src/MulleObjC-startup.m. Learn about the runtime initialization code that runs before main.

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

---

**The main source file for MulleObjC-startup is located at `src/MulleObjC-startup.m` in the repository root, containing the runtime initialization code that executes automatically before `main()`.**

The MulleObjC-startup library provides the essential bootstrap sequence required to initialize the Mulle Objective-C runtime. Understanding the location and contents of the main source file for MulleObjC-startup is crucial for developers debugging startup issues or contributing to the runtime ecosystem.

## Location of the Main Source File

The central implementation of the startup library resides in a single Objective-C source file:

- **`src/MulleObjC-startup.m`** – Contains the essential startup code that initializes the Objective-C runtime, registers the default `NSObject` class, and handles command-line argument processing.

This file is compiled into the static library `libMulleObjC-startup` and linked automatically by the `mulle-sde` build system. The complete source is available directly at the repository path `src/MulleObjC-startup.m`.

## Build System Integration

The project’s CMake configuration explicitly identifies `src/MulleObjC-startup.m` as the definitive source for the library target:

- **[`CMakeLists.txt`](https://github.com/mulle-objc/mulleobjc-startup/blob/main/CMakeLists.txt)** – Declares the `MulleObjC-startup` library target and defines the source files required for compilation.
- **`cmake/reflect/_Sources.cmake`** – Auto-generated CMake reflect file that explicitly lists `src/MulleObjC-startup.m` as the sole source file, ensuring it compiles for every target that links against the library.

This integration guarantees that any executable linking against the MulleObjC framework receives the startup initialization automatically without manual source file inclusion.

## Architectural Purpose of the Startup File

According to the mulle-objc/mulleobjc-startup source code, `src/MulleObjC-startup.m` implements the minimal bootstrap sequence required before any Objective-C code executes. The file handles:

- **Runtime Loader Setup** – Configures the dynamic loading infrastructure necessary for class registration.
- **Default Class Registration** – Ensures fundamental classes including `NSObject` are available immediately.
- **Command-Line Processing** – Prepares `argc` and `argv` for the runtime environment before application code runs.

The public interface is exposed through **[`include/MulleObjC-startup.h`](https://github.com/mulle-objc/mulleobjc-startup/blob/main/include/MulleObjC-startup.h)** (accessed in client code as `<MulleObjC-startup/MulleObjC-startup.h>`), which provides the necessary declarations while encapsulating the implementation details within the `.m` file.

## Using the Startup Library in Your Code

When you link against the `MulleObjC-startup` library, the initialization code runs automatically before `main()` is entered. Here is the typical implementation pattern for a MulleObjC application:

```objc
// main.m – entry point for a program using MulleObjC
#import <MulleObjC-startup/MulleObjC-startup.h>
#import <MulleObjC/MulleObjC.h>

int main(int argc, char *argv[])
{
    // Startup library initialization runs automatically before this point
    @autoreleasepool {
        NSLog(@"Hello from MulleObjC!");
    }
    return 0;
}

```

The bootstrap sequence executes transparently, ensuring the runtime is fully initialized and ready for your Objective-C objects.

## Summary

- The **main source file for MulleObjC-startup** is **`src/MulleObjC-startup.m`**, located in the `src/` directory at the repository root.
- It contains the bootstrap code that initializes the Objective-C runtime before `main()` executes, including loader setup and default class registration.
- The build system ([`CMakeLists.txt`](https://github.com/mulle-objc/mulleobjc-startup/blob/main/CMakeLists.txt) and `cmake/reflect/_Sources.cmake`) explicitly targets this single file for static library compilation.
- Client code includes `<MulleObjC-startup/MulleObjC-startup.h>` to access startup symbols, while the implementation remains encapsulated in `src/MulleObjC-startup.m`.

## Frequently Asked Questions

### Where exactly is the MulleObjC-startup implementation file located in the repository?

The implementation file is located at **`src/MulleObjC-startup.m`** in the root of the mulle-objc/mulleobjc-startup repository. This path is referenced explicitly in the project's CMake configuration files as the primary source for the startup library.

### What is the purpose of the MulleObjC-startup.m file?

The file provides the essential bootstrap sequence that initializes the Mulle Objective-C runtime environment. It sets up the loader infrastructure, registers default classes like `NSObject`, and processes command-line arguments before your application's `main()` function begins execution.

### How does the build system recognize the main source file?

The build system identifies the file through two CMake configuration files: **[`CMakeLists.txt`](https://github.com/mulle-objc/mulleobjc-startup/blob/main/CMakeLists.txt)** declares the library target, while **`cmake/reflect/_Sources.cmake`** auto-generates the explicit source file list containing `src/MulleObjC-startup.m`. This ensures the startup code compiles automatically for any target linking against the library.

### Do I need to manually include the startup source file in my project?

No. When using the `mulle-sde` build system or linking against the provided static library, `src/MulleObjC-startup.m` is compiled and linked automatically. You only need to include the public header `<MulleObjC-startup/MulleObjC-startup.h>` in your source code to ensure proper symbol availability.