Skip to content
inverted-treePublic

About

A library collection of common C helpers.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

17 Commits

Folders and files

Repository files navigation

commonlib

A collection of common C helpers.


C icon

Building a library

Each top-level directory containing a library.mk is a library with the dirname being the name of the library. Make builds only the requested lib and its dependencies, and combines them into one static archive. No external build system is required1.

To build the release version of a specific library, call

make <libname>

If you want the debug version instead, set the BUILD variable to debug

make <libname> BUILD=debug

To get the entire collection as one single archive, use

make all

Debug uses -O0 -g3 -DDEBUG; release uses -O2 -DNDEBUG. Each library target builds and packages its archive and public headers by default.

Linking a library into your code

Running make <libname> creates dist/release/<libname>/lib/lib<libname>.a and dist/release/<libname>/include/, containing the public headers of <libname> and all transitive dependencies. A consumer can link with

cc main.c -Idist/release/<libname>/include dist/release/<libname>/lib/lib<libname>.a -o myapp

Only one archive needs to be linked2.

Important

If you link two independently bundled archives that contain the same dependency, their duplicate implementations can cause symbol conflicts.



Unlicense

Released under the Unlicense. I have dedicated this software to the public domain. You are free to use, modify, distribute, and share this software for any purpose, without restriction.


Footnotes

  1. You still need GNU Make, a C compiler, and ar. ↩

  2. Plus any external system libraries you use. ↩

About

A library collection of common C helpers.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages