morinim / vita

Vita - Genetic Programming Framework
Mozilla Public License 2.0
36 stars 6 forks source link

Usage of library file (libvita.a) #32

Closed HawkTom closed 2 years ago

HawkTom commented 3 years ago

Hello,

I want to use this library in my own project, but I didn't want to place all source files in my project. Therefore, I compile a static Library (libvita.a) as README introducing. But when I want to include it in my project, it raised errors that I didn't have the header file (The namesapces are not declared.).

So, does it exsit one header file which includes all interfaces or I need to include all .h files in my project together with the library file.
Thanks.

morinim commented 3 years ago

You can include the vita.h header file (vita/src/kernel/vita.h), it should be enough.

Anyway consider that vita.h is just a group header:

#if !defined(VITA_VITA_H)
#define      VITA_VITA_H

#include "kernel/ga/i_ga.h"
#include "kernel/ga/i_de.h"
#include "kernel/ga/primitive.h"
#include "kernel/ga/search.h"
#include "kernel/gp/mep/i_mep.h"
/// ...

#endif  // include guard

so you have to deploy all the other header files. There are tools to create a single header form of distribution (e.g. https://github.com/bfgroup/Lyra/blob/develop/tools/gen_single_include.py from Lyra; further details here).

I haven't tried this method yet. I'm going to experiment next week.

Meanwhile if you go ahead please let me know your approach.

morinim commented 3 years ago

The new script tools/single_include.py (derived from https://github.com/bfgroup/Lyra/blob/develop/tools/gen_single_include.py) creates a single header file for the distribution.

The command (from the repository main directory) is:

./tools/single_include.py --src-include-dir src/ --src-include kernel/vita.h --dst-include myvita.h

and myvita.h is the single, global header file for Vita.

Alternatively:

cmake --install build/

creates and install the required include file.

At the moment the global include file should be considered an experimental feature.