How do I run C++ programs in Function Compute?

Updated at:

Function Compute does not include a native C++ runtime. Four approaches let you run C++ code on the platform, each with different trade-offs in implementation effort and runtime performance.

Choose an approach

ApproachImplementation effortPerformance overheadBest for
Rewrite in a supported languageDepends on program complexityDepends on language and scenarioApplications that are not complex
Use a custom runtimeLowLowAll scenarios
Call an executable fileLowHighLatency-insensitive applications, such as asynchronous background file processing
Call a shared libraryHighLowHigh-performance applications

Not sure which approach fits your situation?

  • Rewrite in a supported language — Node.js and Python both have rich ecosystems of libraries. If your C++ logic is straightforward, rewriting it in Python is often the fastest path to production.

  • Use a custom runtime — The lowest-friction option for most teams. Works for virtually any use case. See Overview to get started.

  • Call an executable file — Compile your C or C++ program as a self-contained executable, then invoke it from a supported-language handler using system calls such as fork. Simple to set up, but the process-spawn overhead makes this unsuitable for latency-sensitive workloads.

  • Call a shared library — Compile your C or C++ module as a shared library (.so), then write a Python binding that loads and calls it at runtime.

For a complete list of natively supported languages, see Overview.

Get support

If none of the above approaches resolves your issue, join DingTalk group 64970014484 for technical support.