{"id":20726640,"url":"https://github.com/embeddedartistry/libcpp","last_synced_at":"2025-06-28T06:39:21.184Z","repository":{"id":53820859,"uuid":"116853086","full_name":"embeddedartistry/libcpp","owner":"embeddedartistry","description":"Embedded Systems C++ Library Support (Currently wraps libcxx)","archived":false,"fork":false,"pushed_at":"2024-11-11T17:01:12.000Z","size":445,"stargazers_count":82,"open_issues_count":9,"forks_count":16,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-31T16:14:03.239Z","etag":null,"topics":["cpp","cpp11","cpp14","cpp17","embedded","embedded-cpp","embedded-software","embedded-systems"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/embeddedartistry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-09T18:15:55.000Z","updated_at":"2025-03-10T05:06:56.000Z","dependencies_parsed_at":"2025-01-31T12:10:23.062Z","dependency_job_id":null,"html_url":"https://github.com/embeddedartistry/libcpp","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/embeddedartistry%2Flibcpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/embeddedartistry%2Flibcpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/embeddedartistry%2Flibcpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/embeddedartistry%2Flibcpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/embeddedartistry","download_url":"https://codeload.github.com/embeddedartistry/libcpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247694876,"owners_count":20980733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","cpp11","cpp14","cpp17","embedded","embedded-cpp","embedded-software","embedded-systems"],"created_at":"2024-11-17T04:26:27.533Z","updated_at":"2025-04-07T17:08:13.385Z","avatar_url":"https://github.com/embeddedartistry.png","language":"C++","readme":"# Embedded Artistry libcpp\n\nThis project supplies a C++ standard library and C++ ABI library that can be used for microcontroller-based embedded systems projects.\n\nThis project is based on the clang libc++ and libc++abi libraries. Alternative implementations are provided for various files to support embedded systems usage.\n\nThe builds are highly configurable, allowing you to create a libc++ and libc++abi set that is tuned specifically to your system's needs.\n\n## Table of Contents\n\n1. [About the Project](#about-the-project)\n1. [Project Status](#project-status)\n1. [Getting Started](#getting-started)\n    1. [Requirements](#Requirements)\n    1. [Getting the Source](#getting-the-source)\n    1. [Building](#building)\n    1. [Usage](#installation)\n1. [Configuration Options](#configuration-options)\n1. [Versioning](#versioning)\n1. [How to Get Help](#how-to-get-help)\n1. [Contributing](#contributing)\n1. [License](#license)\n1. [Authors](#authors)\n\n## About the Project\n\nThis project supplies a C++ standard library and C++ ABI library that can be used for microcontroller-based embedded systems projects.\n\nThis project is based on the clang libc++ and libc++abi libraries. Alternative implementations are provided for various files to support embedded systems usage.\n\nThe builds are highly configurable, allowing you to create a libc++ and libc++abi set that is tuned specifically to your system's needs.\n\n**[Back to top](#table-of-contents)**\n\n## Project Status\n\nThis project currently builds libc++ and libc++abi for x86, x86_64, arm, and arm64 processors. All relevant library configuration options have been ported from the CMake builds. See [Configuration Options](#configuration-options) and [meson_options.txt](meson_options.txt) for the list of configurable settings.\n\nThis library has also been tested with [Embedded Artistry libc](https://github.com/embeddedartistry/libc) and is used on multiple Embedded Artistry projects.\n\n**[Back to top](#table-of-contents)**\n\n## Getting Started\n\n### Requirements\n\nThis project uses [Embedded Artistry's standard Meson build system](https://embeddedartistry.com/fieldatlas/embedded-artistrys-standardized-meson-build-system/), and dependencies are described in detail [on our website](https://embeddedartistry.com/fieldatlas/embedded-artistrys-standardized-meson-build-system/).\n\nAt a minimum you will need:\n\n* [`git-lfs`](https://git-lfs.github.com), which is used to store binary files in this repository\n* [Meson](#meson-build-system) is the build system\n* Some kind of compiler for your target system.\n    - This repository has been tested with:\n        - gcc-7, gcc-8, gcc-9\n        - arm-none-eabi-gcc\n        - Apple clang\n        - Mainline clang\n\n#### git-lfs\n\nThis project stores some files using [`git-lfs`](https://git-lfs.github.com).\n\nTo install `git-lfs` on Linux:\n\n```\nsudo apt install git-lfs\n```\n\nTo install `git-lfs` on OS X:\n\n```\nbrew install git-lfs\n```\n\nAdditional installation instructions can be found on the [`git-lfs` website](https://git-lfs.github.com).\n\n#### Meson Build System\n\nThe [Meson](https://mesonbuild.com) build system depends on `python3` and `ninja-build`.\n\nTo install on Linux:\n\n```\nsudo apt-get install python3 python3-pip ninja-build\n```\n\nTo install on OSX:\n\n```\nbrew install python3 ninja\n```\n\nMeson can be installed through `pip3`:\n\n```\npip3 install meson\n```\n\nIf you want to install Meson globally on Linux, use:\n\n```\nsudo -H pip3 install meson\n```\n\n### Getting the Source\n\nThis project uses [`git-lfs`](https://git-lfs.github.com), so please install it before cloning. If you cloned prior to installing `git-lfs`, simply run `git lfs pull` after installation.\n\nThis project is [hosted on GitHub](https://github.com/embeddedartistry/libcpp). You can clone the project directly using this command:\n\n```\ngit clone --recursive git@github.com:embeddedartistry/libcpp.git\n```\n\nIf you don't clone recursively, be sure to run the following command in the repository or your build will fail:\n\n```\ngit submodule update --init\n```\n\n### Building\n\nThe library can be built by issuing the following command:\n\n```\nmake\n```\n\nThis will build all targets for the host system using the default options (specified in [`meson_options.txt`](meson_options.txt)). Build output will be placed in the `buildresults` folder.\n\nYou can clean builds using:\n\n```\nmake clean\n```\n\nYou can eliminate the generated `buildresults` folder using:\n\n```\nmake distclean\n```\n\nYou can also use the `meson` method for compiling.\n\nYou can choose your own build output folder with `meson`, but you must build using `ninja` within the build output folder.\n\n```\n$ meson my_build_output/\n$ cd my_build_output/\n$ ninja\n```\n\nAt this point, `make` would still work.\n\nYou can also use  `meson` directly for compiling.\n\nCreate a build output folder:\n\n```\nmeson buildresults\n```\n\nAnd build all targets by running\n\n```\nninja -C buildresults\n```\n\nCross-compilation is handled using `meson` cross files. Example files are included in the [`build/cross`](build/cross/) folder. You can write your own cross files for your specific processor by defining the toolchain, compilation flags, and linker flags. These settings will be used to compile `libc`. (or open an issue and we can help you).\n\nCross-compilation must be configured using the meson command when creating the build output folder. For example:\n\n```\nmeson buildresults  --cross-file build/cross/arm.txt --cross-file build/cross/gcc_arm_cortex-m4.txt\n```\n\nFollowing that, you can run `make` (at the project root) or `ninja` to build the project.\n\nNote that the standard settings may need to be adjusted when cross-compiling. For example, when using gnu-arm-none-eabi, you will likely need to set `enable-threading=false` and `libcxx-enable-chrono=false`.\n\nAlso note that if you are cross-compiling for ARM using the arm-none-eabi-gcc toolchain, you will need to use **version 9.0 or later**. If you cannot get this version for your platform due to package availability, you can build the most recent compiler version using the [arm-gcc-bleeding-edge](https://github.com/embeddedartistry/arm-gcc-bleeding-edge) project.\n\n**Full instructions for building the project, using alternate toolchains, and running supporting tooling are documented in [Embedded Artistry's Standardized Meson Build System](https://embeddedartistry.com/fieldatlas/embedded-artistrys-standardized-meson-build-system/) on our website.**\n\n### Usage\n\nIf you don't use `meson` for your project, the best method to use this project is to build it separately and copy the headers and library contents into your source tree.\n\n* Copy the `include/` directory contents into your source tree.\n* Library artifacts are stored in the `buildresults/` folder\n* Copy the desired library to your project and add the library to your link step.\n\nExample linker flags:\n\n```\n-Lpath/to/libraries -lc++ -lc++abi\n```\n\nYou can use libcpp as a subproject inside of another `meson` project. Include this project with the `subproject` command:\n\n```\nlibcpp = subproject('libcpp')\n```\n\nThen make dependencies available to your project:\n\n```\nlibcxx_full_dep = libcpp.get_variable('libcxx_full_dep')\nlibcxx_full_native_dep = libcpp.get_variable('libcxx_full_native_dep')\nlibcxx_header_include_dep = libcpp.get_variable('libcxx_header_include_dep')\nlibcxx_native_header_include_dep = libcpp.get_variable('libcxx_native_header_include_dep')\n```\n\nYou can use these dependencies elsewhere in your project:\n\n```\nfwdemo_sim_platform_dep = declare_dependency(\n    include_directories: fwdemo_sim_platform_inc,\n    dependencies: [\n        fwdemo_simulator_hw_platform_dep,\n        fwdemo_platform_dep,\n        libmemory_native_dep,\n        libc_native_dep,\n        libcxx_full_native_dep, # \u003c---- here\n    ],\n    sources: files('boot.cpp', 'platform.cpp'),\n)\n```\n\n## Configuration Options\n\nWell, let's be honest: there are way too many options for this project (see [meson_options.txt](meson_options.txt)). But we support a variety of project-specific options as well as the majority of the useful options provided by the libc++ and libc++abi Cmake projects.\n\nHere are the configurable options:\n\n* `enable-werror`: Cause the build to fail if warnings are present\n* `enable-pedantic-error`: Turn on `pedantic` warnings and errors\n* `force-32-bit`: forces 32-bit compilation instead of 64-bit\n* `os-header-path`: Path to the headers for your OS, if using a custom threading solutions\n* `disable-rtti`: Build without RTTI support (excludes some C++ features such as name demangling)\n* `disable-exceptions`: Build without exception support\n* `use-compiler-rt`: Build with compiler-rt support\n* `always-enable-assert`: Enable assert even with release builds\n* `use-llvm-libunwind`: Tell libc++abi to use the llvm libunwinder (don't change unless you know what you're doing)\n* `libcxx-enable-chrono`: Builds with chrono.cpp\n* `enable-threading`: Build with threading support\n* `libcxx-thread-library`: Select the threading library to use with libc++: none, pthread, or the framework thread shims\n* `libcxx-has-external-thread-api`: Tell C++ to look for an __external_threading header with thread function shims\n* `libcxx-build-external-thread-api`: ???\n* `libcxx-enable-filesystem`: enable filesystem support\n* `libcxx-enable-stdinout`: enable stdio support\n* `libcxx-default-newdelete`: Enable support for the default new/delete implementations\n* `libcxx-silent-terminate`: Enable silent termination. The default terminate handler attempts to demangle uncaught exceptions, which causes extra I/O and demangling code to be pulled in.\n* `libcxx-monotonic-clock`: Enable/disable support for the monotonic clock (can only be disabled if threading is disabled)\n `use-libc-subproject`: When true, use the subproject defined in the libc-subproject option. An alternate approach is to override c_stdlib in your cross files.\n* `libc-subproject`: This array is used in combination with `use-libc-subproject`. The first entry is the subproject name. The second is the cross-compilation dependency to use. The third value is optional. If used, it is a native dependency to use with native library targets.\n\nOptions can be specified using `-D` and the option name:\n\n```\nmeson buildresults -Denable-werror=true\n```\n\nThe same style works with `meson configure`:\n\n```\ncd buildresults\nmeson configure -Denable-werror=true\n```\n\n### Threading\n\nYou can enable threading support with an RTOS using an `__external_threading` header. Supply the include path to your RTOS headers:\n\n```\nmeson buildresults --cross-file build/cross/gcc/arm/gcc_arm_cortex-m4.txt -Dlibcxx-thread-library=threadx -Dos-header-path=../../os/threadx/include\n```\n\n### Blocking new/delete\n\nYou can block the `new` and `delete` operators by setting the `libcxx-default-newdelete` to `false`:\n\n```\nmeson buildresults -Dlibcxx-default-newdelete=false\n```\n\nYou can also use `meson configure`:\n\n```\ncd buildresults\nmeson configure -Dlibcxx-default-newdelete=false\n```\n\nIf you are using libcpp as a subproject, you can specify this setting in the containing project options.\n\n### Using a Custom Libc\n\nThis project is designed to be used along with a `libc` implementation. If you are using this library, you may not be using the standard `libc` that ships with you compiler. This library needs to know about the particular `libc` implementation during its build, in case there are important differences in definitions.\n\nThere are two ways to tell this library about a `libc`:\n\n1. [Override `c_stdlib` in a cross-file](https://mesonbuild.com/Cross-compilation.html#using-a-custom-standard-library), which will be automatically used when building this library.\n2. Set `use-libc-subproject` to `true`\n    1. By default, this will use the [Embedded Artistry libc](https://github.com/embeddedartistry/libc)\n    2. You can specify another Meson subproject by configuring `libc-subproject`. This is an array: the first value is the subproject name, the second the libc dependency variable, and the third is an optional native dependency that will be used with native library variants.\n\nNOTE: External libc dependencies are only used for building the library. They are not forwarded through dependencies. You are expected to handle that with the rest of your program.\n\n## Versioning\n\nThis project itself is unversioned and simply pulls in the latest libc++ and libc++abi commits periodically.\n\n## Need help?\n\nIf you need further assistance or have any questions, please [file a GitHub Issue](https://github.com/embeddedartistry/libmemory/issues/new) or send us an email using the [Embedded Artistry Contact Form](http://embeddedartistry.com/contact).\n\nYou can also reach out on Twitter: [\\@mbeddedartistry](https://twitter.com/mbeddedartistry/).\n\n## Contributing\n\nIf you are interested in contributing to this project, please read our [contributing guidelines](docs/CONTRIBUTING.md).\n\n## License\n\nThis container project is licensed under the MIT license.\n\nlibc++ and libc++abi (and the llvm project in general) are released under [a modified Apache 2.0 license](libcpp/LICENSE.txt). Source files which have been modified are licensed under those terms.\n\n## Authors\n\n* **[Phillip Johnston](https://github.com/phillipjohnston)** - *Initial work* - [Embedded Artistry](https://github.com/embeddedartistry)\n\n**[Back to top](#table-of-contents)**\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fembeddedartistry%2Flibcpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fembeddedartistry%2Flibcpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fembeddedartistry%2Flibcpp/lists"}