Embedding Decision¶
Prerequisites¶
To embed Decision into your C/C++ application, you will need 2 things:
The Decision header files.
A compiled Decision library, which can be static or dynamic.
The best way to get both is to build Decision from the source code. There are
instructions on how to build Decision from source both in the README.md
file in the root of the project, and more detailed instructions in the
user manual.
When you build Decision, not only do you get the executable you probably intended, but you also get a compiled library as well!
So if you have the header files and the libraries at hand, here is how you can embed Decision into your program:
Windows¶
This section assumes you are using Visual Studio to build your C/C++ project.
To get Visual Studio to see the header files, you can do the following:
In the Solution Explorer, right-click on the project and select Properties.
In C/C++/General, in the Additional Include Directories entry, either insert the path to the header files manually, or click on the arrow button to the right to use the in-built path editor.
Now, no errors should appear about missing Decision header files, and it should start auto-completing functions for you.
To get Visual Studio to link with the compiled Decision library:
In the Solution Explorer, right-click on the project and select Properties.
In Linker/General, in the Additional Library Directories entry, either intert the path to the folder where the library is located manually, or click on the arrow button on the right to use the in-built path editor.
In Linker/Input, in the Additional Dependencies entry, enter into the semi-colon seperated list “decision.lib”, without quotes.
Now, when you build and run the project, it should link properly.
Note
If you built a DLL version of the Decision library, if your program is complaining that it cannot find decision.dll, copy that file to the same folder as the program that is being run.
Linux¶
This section assumes you are using gcc manually to build your C/C++ project.
To get your program to see the header files, add the -I
flag when you are
compiling the C/C++ file:
gcc -I/home/USERNAME/decision/src -c main.c
To get your program to link with the library, use the -ldecision
and -L
flags:
gcc main.o -o main -L/home/USERNAME/decision/build -ldecision
Note
If you installed Decision with sudo make install
into a common prefix
like /usr/local
, then you may omit the -L
flag.
Installing Decision is generally recommended, as it means that if you link with the dynamic library (libdecision.so), you don’t have to give an environment variable every time to tell the executable where the library lives, it should just find it under a known list of directories.