Example Projects

See IncludeBuild in action with these practical examples

Basic

A minimal example that demonstrates the simplest use of IncludeBuild. Just include build.h, call ib_init() and ib_build() - that's it!

Beginner
Single File
/**
 * IncludeBuild Basic Example
 */
#include "../../build.h"
#include <stdio.h>

int main() {
    // Initialize IncludeBuild
    ib_init();
    
    // Enable verbose output
    ib_set_verbose(true);
    
    // Build the project
    ib_build();
    
    printf("\nBuild complete!\n");
    return 0;
}
View Example

Multi-file

Demonstrates how IncludeBuild automatically handles a project with multiple source files and resolves dependencies between them.

Intermediate
Multiple Files
/**
 * IncludeBuild Multi-File Example
 */
#include "../../build.h"
#include <stdio.h>

int main() {
    // Initialize IncludeBuild
    ib_init();
    
    // Enable verbose output
    ib_set_verbose(true);
    
    // Build the project - build.h finds all source files automatically
    ib_build();
    
    printf("\nBuild complete!\n");
    return 0;
}
View Example

Library

Shows how to create a complete library with static and dynamic versions plus tests with just TWO LINES of code.

Advanced
Libraries
/**
 * IncludeBuild Library Example - The Magic Solution
 */
#include "../../build.h"

int main(int argc, char** argv) {
    // Initialize IncludeBuild
    ib_init();
    
    // Enable verbose output
    ib_set_verbose(true);
    
    // Build the library - this handles everything: static, dynamic, tests
    return ib_build_library("logger", argc, argv) ? 0 : 1;
}
View Example

Game

A complete Pong game using the Raylib external library, demonstrating IncludeBuild's ability to handle dependencies and cross-platform builds.

Game
External Libraries
/**
 * IncludeBuild Game Example
 */
#include "../../build.h"
#include <stdio.h>

int main() {
    // Initialize IncludeBuild
    ib_init();
    
    // Enable verbose output
    ib_set_verbose(true);
    
    // Add Raylib and its dependencies
    ib_add_libraries("raylib", "GL", "m", "pthread", "dl", "rt", "X11", NULL);
    
    // Build the project
    ib_build();
    
    printf("\nBuild complete!\n");
    return 0;
}
View Example

Logging

Demonstrates IncludeBuild's logging features with different verbosity levels, allowing for detailed build information and debugging.

Utility
Debug
/**
 * IncludeBuild Logging Example
 */
#include "../../build.h"
#include <stdio.h>
#include <string.h>

int main(int argc, char** argv) {
    // Initialize IncludeBuild
    ib_init();
    
    // Enable verbose output
    ib_set_verbose(true);
    
    // Set a different log level if specified
    if (argc > 1) {
        if (strcmp(argv[1], "debug") == 0)
            ib_set_log_level(IB_LOG_DEBUG);      // Most verbose
        else if (strcmp(argv[1], "warn") == 0)
            ib_set_log_level(IB_LOG_WARN);       // Warnings and errors
        else if (strcmp(argv[1], "error") == 0)
            ib_set_log_level(IB_LOG_ERROR);      // Errors only
    }
    
    // Build the project
    ib_build();
    
    return 0;
}
View Example

Custom Limits

Demonstrates how to customize IncludeBuild's internal limits for larger projects by defining constants before including build.h.

Advanced
Customization
/**
 * IncludeBuild Custom Limits Example
 */

// Define custom limits before including build
#define IB_MAX_FILES 2000      // Default is 1000
#define IB_MAX_DEPS 200        // Default is 100
#define IB_MAX_INCLUDE_DIRS 100 // Default is 50

#include "../../build.h"
#include <stdio.h>

int main() {
    // Initialize IncludeBuild
    ib_init();
    ib_set_verbose(true);
    
    // Print custom limits
    printf("\nCustom limits in effect:\n");
    printf("  IB_MAX_FILES: %d\n", IB_MAX_FILES);
    printf("  IB_MAX_DEPS: %d\n", IB_MAX_DEPS);
    
    // Build the project
    ib_build();
    
    return 0;
}
View Example

Create Your Own Examples

These examples are just the beginning. IncludeBuild is flexible enough to handle many different use cases. We encourage you to experiment with these examples and create your own!

If you develop an interesting example, consider contributing it back to the project.

Contribute to IncludeBuild