Neargye/hello_tf_c_api

Neural Network TensorFlow C API

What it solves

Building and running TensorFlow in C or C++ can involve complex setup and boilerplate code for managing memory, sessions, and graphs. This project provides clear examples and a lightweight C++ helper library to make using the TensorFlow C API straightforward across Windows, Linux, and macOS.

How it works

The project uses CMake to automatically download a TensorFlow Python wheel, extract its native libraries and headers, and link against them without requiring a full TensorFlow Python installation. It offers both raw C API examples (like loading graphs and creating tensors) and C++ helper routines that simplify session management, memory cleanup, and tensor creation.

Who it’s for

Developers looking to integrate TensorFlow into C or C++ applications who want practical code examples and utilities to handle low-level setup, memory allocation, and inference.

Highlights

  • Includes raw C API examples for checking versions, loading graphs, and allocating tensors.
  • Provides a C++ helper library for short setup, session running, and batch inference.
  • Supports optional OpenCV integration for handling image files.
  • Works across Windows, Linux, and macOS using CMake.

Related

  • Project
  • Project
  • Project
  • Project
  • Project