HOW TO CREATE A PROGRAM
BASED ON THE B++ LIBRARY ? |
 |
Before trying to create a program based on the B++ Library, you must configure
and reach to compile the library. For more details, see the
. To
illustrate how to create a program, we will consider the Make Doc program of the B++ Library
that semi automatically generates the documentation of the modules.
You first have to code your own functions, classes... You can put them in a
module. For instance, the elements of the Make Doc program are located in the module
Program/Make_doc . After that, you have to create the main function, the one that will
start your program. For instance, the Make Doc program has a file called
make_doc.cpp that must be located in the same folder as the options.hpp
file (cf. ).
This file contains:
#include <bpp/display/console.hpp>
#include <bpp/program/make_doc.hpp>
using namespace bpp;
int main(int argc,const char * argv[]) {
int result;
displayConsole::clDisplay display;
standard::openLibrary(display);
result=programMakeDoc::run(argc,argv);
standard::closeLibrary();
exit(result);
} |
To use any element of the B++ Library, you first need to initialize the library
with the standard::openLibrary function. The parameter given to the function is an
object that represents the display. Here we choose the display contained in the
Display/Console module, but you can define your own display (cf.
). When you do
not need the library anymore, you have to call the standard::closeLibrary function to
terminate properly the library.
To build the program, you have different solutions. If you use a development
environment, make a project that contains the file with the main function, the files
describing your program and the libraries of the B++ Library you need. The other way is to create a
makefile. We propose the following.
OPTIONS_EXE =
MAKE_DOC_DEPENDENCY = -lbpp_meta_model -lbpp_text_format \
-lbpp_calendar
-lbpp_standard \
-lbpp_display
COMPILE_EXE = $(GCC) -L$(LIBRARY_PATH) $(OPTIONS_EXE) \
$(OPTIONS_THREAD) $(OPTIONS_GLPK) $(OPTIONS_CPLEX)
MAKE_DOC_OBJECTS = $(OBJECTS_PATH)/make_doc.$(OBJ) \
$(OBJECTS_PATH)/bpp/program/make_doc/console.$(OBJ)
make_doc.exe : $(MAKE_DOC_OBJECTS)
$(COMPILE_EXE) $(MAKE_DOC_OBJECTS) \
$(MAKE_DOC_DEPENDENCY) -o $@ |
Here are some comments on the makefile.
OPTIONS_EXE |
Compilation options given to the compiler. |
MAKE_DOC_DEPENDENCY |
List of the libraries you need to compile your program. You have to put in it all the B++
Library modules you use in your program. |
COMPILE_EXE |
Command to compile and link the program. |
MAKE_DOC_OBJECTS |
List of the objects you need to link your program. |
make_doc.exe |
Rule to build the program. |
To determine the list of the libraries you need to compile a program (e.g.
MAKE_DOC_DEPENDENCY ), here is a diagram. It represents all the libraries of the B++
Library and their dependency.
When your program uses a module, it actually needs the library containing the
implementation of the module and all the libraries it depends on. For instance, the Make Doc
program uses Meta_model so needs bpp_meta_model and the libraries it
depends on, meaning bpp_text_format , bpp_calendar ,
bpp_standard and bpp_display . In the case you use static libraries, the
order of the libraries in the command line may be important. With GNU compilers, we recommend you
to list them from the lower library in the hierarchy (e.g. bpp_meta_model ) to the
higher one (e.g. bpp_display ). For more details on how to create a program, see the
examples in the library folder.
To be run, a program needs an initialization file. Its name and location is
settled in the Display/Console module (cf.
). By default,
the file is called bpp_library.ini and is located in the folder pointed by the
environment variable BPP_TOOLS (or BPP_TESTING if the library is compiled
in the testing mode). The library needs external parameters stored in this file. Here is a list of
these parameters. All of them are not always needed, it depends on the modules the program
effectively uses.
ampl_location |
Full name and location of the AMPL software. Put dummy.exe if this software is not
available in your environment. Requested only if the AMPL_YES option is activated in
the options.hpp file. |
class_path |
List of paths where the Java class files are searched. Requested only if the
JAVA_NATIVE_INTERFACE_YES option is activated in the options.hpp
file. |
cplex_location |
Full name and location of the CPLEX software. Put dummy.exe if this software is
not available in your environment. Requested only if the CPLEX_YES option is activated
in the options.hpp file. |
data_location |
Location of the data needed by the library. |
default_html_template |
Full name and location of the file containing a template of HTML document needed to generate
HTML files. |
epsilon |
Maximum positive real number that is considered to be equal to zero. |
information_displayed |
Indicates if detailed information must be displayed (yes or no ). |
java_maximum_heap_size |
Maximum heap size of the Java Virtual Machine (in megabytes), usually set to 16 Mb. Requested
only if the JAVA_NATIVE_INTERFACE_YES option is activated in the
options.hpp file. |
java_minimum_heap_size |
Initial heap size of the Java Virtual Machine (in megabytes), usually set to 1 Mb. Requested
only if the JAVA_NATIVE_INTERFACE_YES option is activated in the
options.hpp file. |
java_virtual_machine_location |
Full name and location of the Java Virtual Machine dynamic library. Put dummy.dll
if the library is not available in your environment. Requested only if the
JAVA_NATIVE_INTERFACE_YES option is activated in the options.hpp
file. |
random_seed |
Seeds of the random numbers generator. 0 means that the program will choose itself a seed based
on the internal clock of the computer. |
temporary_location |
Location where temporary files will be written. |
testing_location |
Location where the testing results will be placed. Requested only if the
TESTING_MODE option is activated in the options.hpp file. |
time_zone |
Time zone of the local time. |
For more details, see the examples in the library folder.
|
|
Copyright (c) 1999-2016 - Bruno Bachelet - bruno@nawouak.net -
http://www.nawouak.net |
Permission is granted to copy, distribute and/or modify this document under the
terms of the GNU Free Documentation License, Version 1.1 or any later version
published by the Free Software Foundation. See this license for more details (http://www.gnu.org). |
|
|
|