Build a C Project
For Language versions and other build-environment specific information visit our reference pages:
This guide covers build environment and configuration topics specific to C projects. Please make sure to read our Onboarding and General Build configuration guides first.
CI Environment for C Projects #
Travis CI VMs are 64-bit and provide versions of:
- gcc
- clang
- core GNU build toolchain (autotools, make), cmake, scons
C projects on Travis CI assume you use Autotools and Make by default.
For precise versions on the VM, please consult “Build system information” in the build log.
Dependency Management #
Because there is no dominant convention in the community about dependency management, Travis CI skips dependency installation for C projects.
If you need to install dependencies before your tests can run, override the
install: key in your .travis.yml:
install: make get-deps
See the build configuration guide to learn more.
Test against Compilers #
You can test projects against either GCC or Clang or both. To do so, specify
the compiler to use using the compiler: key in .travis.yml. For example, to
build with Clang:
compiler: clang
or both GCC and Clang:
compiler:
- clang
- gcc
Testing against two compilers will create (at least) 2 rows in your build
matrix. For each row, Travis CI C builder will export the CC and CC_FOR_BUILD env variables to
point to either gcc or clang.
OpenMP Projects #
OpenMP projects should set the environment variable OMP_NUM_THREADS to a
reasonably small value (say, 4). OpenMP detects the cores on the hosting
hardware, rather than the VM on which your tests run.
MPI Projects #
The default environment variable $CC is known to interfere with MPI projects.
In this case, we recommend unsetting it:
before_install:
- test -n $CC && unset CC
Build Config Reference #
You can find more information on the build config format for C in our Travis CI Build Config Reference.