Installing C API for Tensorflow on Macbook M1


I am trying to install C API of tensorflow on Macbook M1 to execute it in Go. I followed this guide by tensorflow developers but got stuck when running the hello_tf.c file with this command gcc hello_tf.c -ltensorflow -o hello_tf.

This is hello_tf.c file

#include <stdio.h>
#include <tensorflow/c/c_api.h>

int main() {
  printf("Hello from TensorFlow C library version %s\n", TF_Version());
  return 0;

And this is the error log:

ld: warning: ignoring file /usr/local/lib/libtensorflow.2.7.0.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
  "_TF_Version", referenced from:
      _main in hello_tf-6f1778.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation

Any suggestions on how to get the compilation fixed?


Here’s a guide on how to build a version from scratch since outdated or legacy versions of software typically are harder to install especially when it comes to libraries.

Answered By – Darth-CodeX

Answer Checked By – Jay B. (GoLangFix Admin)

Leave a Reply

Your email address will not be published.