Polyman Documentation - v3.0.0
    Preparing search index...

    Function compileCPP

    • Compiles a C++ source file using g++. Uses -O2 optimization and the C++ standard from Config.json (cppStandard, default C++23). The problem root (current working directory) is added as a quoted-include search path so sources in subdirectories can #include "testlib.h". Goes through the compilation cache: when the source, its local headers, the flags, and the compiler are unchanged, the cached binary is restored and g++ is not run. A testlib program is compiled against a declarations-only testlib and linked with testlib compiled once per problem (see prebuilt-testlib.ts), falling back to the original header.

      Parameters

      • sourcePath: string

        Path to the .cpp / .cc / .cxx source file

      • Optionaloptions: { cppStandard?: string } = {}

        Compilation overrides

        • OptionalcppStandard?: string

          Standard to pass as -std=; when omitted it is resolved from Config.json

      Returns Promise<void>

      Resolves once the executable is written next to the source (same path, extension stripped)

      If file is not a C++ source or compilation fails

      await compileCPP('solutions/main.cpp');
      // Produces: '/path/to/solutions/main'