# How to use system libraries in a Clang target?

**URL:** <https://forums.swift.org/t/how-to-use-system-libraries-in-a-clang-target/81371>\
**Category:** Using Swift\
**Tags:** linux, packagemanager, clang\
**Created:** [July 29, 2025, 1:57pm UTC](https://forums.swift.org/t/how-to-use-system-libraries-in-a-clang-target/81371 "2025-07-29T13:57:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lancelotbronner](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lancelotbronner/32/22071_2.png) [@Lancelotbronner](https://forums.swift.org/u/Lancelotbronner)\
**Post date:** [July 29, 2025, 1:57pm UTC](https://forums.swift.org/t/how-to-use-system-libraries-in-a-clang-target/81371/1 "2025-07-29T13:57:05Z")

</div>

I have a Swift target `RaylibKit` wrapping a C library target `raylib` which depends on a system library `X11`. I can make the system target and use it in Swift but `raylib` still can't find the headers (or PC file).

Here's the system target definition:

```swift
.systemLibrary(name: "X11", pkgConfig: "X11", provides: [
    // ...
]),

```

Here's the X11 module map:

```modulemap
module X11 [system] {
    module Xlib {
        header "/usr/include/X11/Xlib.h"
    }
    module X {
        header "/usr/include/X11/X.h"
    }
    link "X11"
}

```

Anyone successfully done this \*without\* using `unsafeFlags`? Until their removal is in stable toolchains and Xcode I don't want to rely on them.
