# C++ libraries linking

DevFeed: [C++ libraries linking](<https://devfeed.tech/articles/c-libraries-linking-22393.md>)

Original publisher: [Read original article](<https://www.red-lang.org/2026/07/c-libraries-linking.html>)

Author: Nenad Rakocevic (noreply@blogger.com)

Published: 2026-07-29T19:07:38Z

Content type: release

Language: en

Sources: [Red](<https://devfeed.tech/sources/red.md>)

Topics: [static linking](<https://devfeed.tech/topics/static-linking.md>), [Red](<https://devfeed.tech/topics/red.md>), [c/c++](<https://devfeed.tech/topics/c-c-plus-plus.md>), [toolchain](<https://devfeed.tech/topics/toolchain.md>), [MSVC](<https://devfeed.tech/topics/msvc.md>), [clang](<https://devfeed.tech/topics/clang.md>), [linker](<https://devfeed.tech/topics/linker.md>)

Tags: [arm](<https://devfeed.tech/tags/arm.md>), [build-tools](<https://devfeed.tech/tags/build-tools.md>), [c](<https://devfeed.tech/tags/c.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [clang](<https://devfeed.tech/tags/clang.md>), [exceptions](<https://devfeed.tech/tags/exceptions.md>), [gcc](<https://devfeed.tech/tags/gcc.md>), [gnu](<https://devfeed.tech/tags/gnu.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [libstdc-plus-plus](<https://devfeed.tech/tags/libstdc-plus-plus.md>), [linker](<https://devfeed.tech/tags/linker.md>), [linking](<https://devfeed.tech/tags/linking.md>), [linux](<https://devfeed.tech/tags/linux.md>), [macos](<https://devfeed.tech/tags/macos.md>), [msvc](<https://devfeed.tech/tags/msvc.md>), [red](<https://devfeed.tech/tags/red.md>), [runtime](<https://devfeed.tech/tags/runtime.md>), [static-linking](<https://devfeed.tech/tags/static-linking.md>), [templates](<https://devfeed.tech/tags/templates.md>), [toolchain](<https://devfeed.tech/tags/toolchain.md>)

## AI overview

The Red toolchain can now statically link C++ libraries and include their runtime on Windows, Linux (x86 and ARM), and macOS, using the existing import system and compilation switch; it accepts native object formats from MSVC, GCC, and clang. Requirements differ by platform: Windows needs Visual Studio Build Tools with the C++ workload for C++ libraries or code using Microsoft's static runtime; Linux needs GCC runtime archives beside the library; macOS needs no additional runtime setup. The excerpt says imported functions must expose a C interface, so C++ classes or templates need a thin C shim, and exceptions should be caught within exported functions. Link-time-optimized objects are unsupported, and Windows builds should use the static runtime. The stated current constraint is support for 32-bit libraries while the 64-bit toolchain is pending.

## Source excerpt

When we introduced static linking of C libraries, the promise was simple: name a .lib or .a archive in your #import, compile with -s, and ship one self-contained executable, no DLLs riding along, nothing to install on the target machine. There was one big frontier left, and everyone saw it coming: the libraries people want most (vision, GUI, audio, machine learning) are written in C++. A C++ library is a very different animal to link: it brings global constructors, exceptions, RTTI, templates, thread-local storage, and an entire language runtime that expects to be wired up just so. Until now, that was the line where you switched back to DLLs. That line is gone. The Red toolchain now statically links C++ libraries too (their runtime included) on every platform Red targets: Windows, Linux (x86 and ARM), and macOS. The best part: nothing changes. It is the same import system and same compilation switch: red -r -s myapp.red Libraries built with MSVC, GCC or clang are all accepted, in their native object formats. What you need preinstalled ➤ Windows: for C++ libraries (or C code built against Microsoft's static runtime), install the free Visual Studio Build Tools with the "Desktop development with C++" workload. Just one installer, and Red locates everything by itself: no vcvarsall, no PATH, no environment variables. Plain C libraries still need nothing at all and that now extends to C libraries touching COM, DirectX or MediaFoundation: the GUID constants such code references ship inside the toolchain, so a fresh Windows 11 with only red-toolchain executable on it links them! ➤ Linux: the GNU runtime archives from your distribution's gcc packages (libstdc++.a, libgcc.a and friends) placed next to your library. If one is missing, the linker names exactly what it needs. ➤ macOS: nothing beyond the toolchain; the system C++ runtime binds automatically. Some constraints 32-bit libraries for now, until the 64-bit toolchain is ready. The imported surface must be C (extern "C",