This is the guide to follow if you just want to use the libraries in your project, without running the test suite.
If you want to contribute or run the test suite, check the Building (Contributor) page.
Principles
- Libraries always meant to be compiled together with your existing project
- All libraries do not require any build system (you're free to use your favorite!)
- For the above reasons you don't really build the libraries
- You add or use them to your project just as another source file
Use in your project
- Add the
SC.cppunity build file to your build system of choice (if any!). - Headers in
Libraries/**SomeLibrary**/*.hare public. - Headers in
Libraries/**SomeLibrary**/[Internal | Tests]are NOT public.
Note: Libraries can be used from normal C++ projects by default. SC library code still avoids STL containers, exceptions, RTTI, and hidden allocations, but public integration no longer requires an opt-in macro for standard C/C++ headers. SC-build also defaults to normal C++ runtime linkage; set
project.link.linkStdCpp = falseonly when you intentionally want to avoid linking the C++ standard-library runtime. If you want the stricter historical no-stdlib mode, defineSC_INCLUDE_STD_CPP=0andSC_PROVIDE_CPP_RUNTIME_SHIMS=1, then check Disable the C++ standard library.
macOS
- Add
SC.cpp(located in project root) to your build - Include any public header located at
Libraries/**SomeLibrary**/SomeHeader.h - Link:
CoreFoundation.frameworkCoreServices.framework
Linux
- Add
SC.cpp(located in project root) to your build - Include any public header located at
Libraries/**SomeLibrary**/SomeHeader.h - Link:
libdl(-ldl)libpthread(-lpthread)
Windows
- Add
SC.cpp(located in project root) to your build - Include any public header located at
Libraries/**SomeLibrary**/SomeHeader.h
Note: on Windows the following libraries are already implicitly linked through
#pragma comment(lib, ...)
Ws2_32.libntdll.libRstrtmgr.libDbgHelp.lib
If you use the Plugin library without SC::Build, make sure the host executable defines
SC_EXPORT_LIBRARY_<LIBRARY>=1 for each Sane C++ library that must be visible to plugins; on Linux also add
-rdynamic to the host executable link step.
Single Files Amalgamation
Sane C++ Libraries can be consumed also as single-file amalgamated files.
To generate them in _Build/_SingleFileLibraries run:
python3 Support/SingleFileLibs/python/amalgamate_single_file_libs.py
alternatively if you have node.js installed run:
node Support/SingleFileLibs/javascript/cli.js --repo-root . --ref HEAD --all --out _Build/_SingleFileLibrariesJS
As a third alternative you can assemble them in the browser at the SingleFileLibs page