Skip to content

Latest commit

 

History

History
101 lines (64 loc) · 3.21 KB

building.md

File metadata and controls

101 lines (64 loc) · 3.21 KB

Building

Building can be a bit tricky because of the many dependencies. It is recommended to follow the building locally guide for building the project. However, there is also a provided devcontainer approach that allows for easy development.

Devcontainer

For convenient development in VSCode, a devcontainer can be used. Simply open the project in VSCode and hit F1, type Remote-Containers: Reopen in Container and wait for the container to build.

The provided .devcontainer/devcontainer.json contains all required dependencies and also mounts the source code into the container, so one can immediately start coding. When the container starts, a development server is started that can be reached at localhost:8080. The server automatically reloads the application on any code changes.

Note: Ensure Docker and VSCode with Remote Development extension are installed.

Building locally

Install prerequisites

Install TensorFlow Lite C library

Download precompiled TensorFlow Lite C library for Linux from https://github.com/tphakala/tflite_c/releases/tag/v2.14.0

Copy libtensorflowlite_c.so to /usr/local/lib and run ldconfig

sudo cp libtensorflowlite_c.so /usr/local/lib
sudo ldconfig

Clone tensorflow repository, this is required for header files to be present while compiling with CGO

mkdir ~/src
cd ~/src
git clone https://github.com/tensorflow/tensorflow.git

Checkout TensorFlow v2.14.0 release

cd tensorflow
git checkout tags/v2.14.0

Building BirdNET-Go

Clone BirdNET-Go repository

git clone https://github.com/tphakala/BirdNET-Go.git

Build BirdNET-Go by make, compiled binary will be placed in go-birdnet/bin directory

cd BirdNET-Go
make

Compiling for Windows

Windows build is cross compiled on Linux, for this you need MinGW-w64 on your build system

  sudo apt install mingw-w64-tools gcc-mingw-w64-x86-64 gcc-mingw-w64-i686

Download precompiled TensorFlow Lite C library for Windows from https://github.com/tphakala/tflite_c/releases/tag/v2.14.0

Copy libtensorflowlite_c.dll to /usr/x86_64-w64-mingw32/lib/

sudo cp libtensorflowlite_c.dll /usr/x86_64-w64-mingw32/lib/

Clone tensorflow repository, this is required for header files to be present while compiling with CGO

mkdir ~/src
cd ~/src
git clone https://github.com/tensorflow/tensorflow.git

Cross #compiling BirdNET-Go

Clone BirdNET-Go repository

git clone https://github.com/tphakala/BirdNET-Go.git

Build BirdNET-Go by running make windows

cd BirdNET-Go
make windows

Windows executable is in bin/birdnet.exe, copy this and libtensorflowlite_c.so to your Windows system, library file must be in PATH for birdnet.exe to run properly.

Yes it is correct that you need libtensorflowlite_c.dll in /usr/x86_64-w64-mingw32/lib/ for compile process, and on Windows you need libtensorflowlite_c.so for runtime. This sounds backwards but this is how it works.