Artificial Intelligence TechC++C++11C++14C++17Code SnippetLanguage FeatureLearn C++

How To Import FANN Library For C++ Builder Windows Projects

This article is about to help you on implementing an Artificial Neural Network by using FANN Library developed by Steffen Nissen. It supports more than 20+ programming languages ( including Delphi and C++ Builder. You can reach full information and documentation here and you can download FANN source files from their web page ((

1: Download FANN Library package from Nissen’s official web page ( This package includes binaries, cmake files, datasets, examples, source codes in the src folder, and some examples.

2: Create a new C++ Builder Application. Add a Panel (Panel1) that has 32 pixels in height and two Buttons (TEST, TRAIN) into it. Align Panel to the bottom of Form1. Add a Memo (Memo1) into the form and make it a client. This will be our visual output place 

3: Create FANN_Test folder and save all project files with “FANN_” prefix into this folder as listed below; 

4: Now we need source files to compile with our application. Unzip the package, copy “src” folder from this folder into this FANN_Test folder. Make your RADS/C++ Builder/Delphi IDE size smaller and drag the src folder from FANN_Test to Project Manager on the “FANN_Project1.exe”. When IDE asks “Would you like to add the selected files to the project …” confirm with Yes. 

5: We need to include a folder of FANN for headers. From the IDE menu go to Project -> Options ->C++ Compiler->Directories and Conditionals->Include File Search path. Add here “src/include” folder which is in our FANN_Test folder

6: Now you can add a header into our FANN_Unit1.cpp. Below #include “FANN_Unit1.h” line add this #include “floatfann.h”. 

If you do all steps now we implemented FANN library into our project with its original sources without any tweaks or changes on the original files. That means FANN source files and headers are very friendly because of their native C codes.

7: Now let’s test if all is fine. Build all projects from Projects -> Build All Projects menu. If Success that means all is fine. if there are errors please check the steps above. 

Go to Form view and double click to TRAIN button and add below ,

 If you want to compile for other compilers don’t forget to add include search path “src/include” to its project options as we do above. Please check examples, other commands, and options of FANN Library to understand its mechanism.

Double click to TEST button and add below;


Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He was born in 1974, Eskisehir-Turkey, started coding in college and graduated from the department of Mechanical Engineering of Eskisehir Osmangazi University in 1997. He worked as a research assistant at the same university for more than 10 years. He received his MSc and PhD degrees from the same department at the same university. Since 2012, he is the founder and CEO of Esenja LLC Company. He has married and he is a father of a son. Some of his interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20Learn C++Syntax

What Is Deleted Implicitly-declared Copy Assignment Operator In C++?

C++C++11C++14C++17C++20Learn C++Syntax

What Is A Forced (Default) Copy Assignment Operator In Modern C++

C++C++11C++14C++17C++20Learn C++Syntax

What is Implicitly-declared Copy Assignment Operator In C++?

C++C++11C++14C++17C++20Learn C++Syntax

What is Avoiding Implicit Copy Assignment In C++?

Worth reading...
Learn C++ With Back to Basics: Class Layout by Stephen Dewhurst (CppCon 2020) Video