ct-build-static-library¶
Generate a static library from a root source file in one shot¶
- Author:
- Date:
2025-11-26
- Version:
10.0.6
- Manual section:
1
- Manual group:
developers
SYNOPSIS¶
ct-build-static-library SOURCE [CT-CREATE-MAKEFILE OPTIONS]
DESCRIPTION¶
ct-build-static-library bundles the discovery + Makefile + build sequence
needed to produce a traditional .a archive from a designated translation
unit. The script performs the following steps:
Treat the first argument as the root implementation file (
SOURCE).Use
ct-filelist --filter=source --style flatto enumerate every source file that must be compiled to satisfy that root target.Run
ct-create-makefile --staticwith the root file, the discovered file list, and all remaining user arguments.Invoke
make -j$(ct-jobs)to build the archive using the recommended level of parallelism.
All additional positional or option arguments after SOURCE are passed
unchanged to ct-create-makefile so the same variant, compiler flag, output
directory, or cache settings you normally rely on continue to work.
OPTIONS¶
SOURCERequired first argument. Points to the canonical implementation file whose include graph determines which translation units belong in the archive.
- Remaining options
Every subsequent flag is forwarded to
ct-create-makefile. Commonly used options include--variant,--cas-objdir,--bindir,--magic, and the various--append-*FLAGSswitches. Seect-create-makefile(1) for the full option list.
ENVIRONMENT¶
CT_JOBSOverrides the job count returned by
ct-jobsfor the finalmakerun.ct.confProvides shared defaults for variants, include paths, caches, and toolchain settings used during Makefile generation.
EXAMPLES¶
Build libmath.a from library/math.cpp using the release variant:
ct-build-static-library library/math.cpp --variant=release
Place intermediate files under out/ while appending custom flags:
ct-build-static-library src/core.cpp --cas-objdir=out/obj --bindir=out/lib \
--append-CXXFLAGS="-fvisibility=hidden"
SEE ALSO¶
ct-build-dynamic-library (1), ct-create-makefile (1), ct-filelist (1), ct-jobs (1)