The process of creating an executable uses two steps:
- Compile each source file to create corresponding object files
- Linking the object files to create an executable or a library
Because your project is also building a library, you have to do the second step twice (one time for the library and one time for the executable).
The G++ can perform both steps (compiling and linking) with one command. This is usually done with small builds containing only a single or a few source files. Each process (compiling and linking) has it's own set of process specific command line options.
The error
Face_test.cpp:41:57: fatal error: dlib/image_processing/frontal_face_detector.h: No such file or directory
compilation terminated.
occurs when compiling the source file
Face_test.cpp. It tells you that the include file from the message could not be found. It is not related to any library because it happened during compilation (not linking).
Knowing now about the two build steps you should become familiar with the related options (
Invoking GCC - Using the GNU Compiler Collection (GCC)[
^]).
If your first command (compiling the file
source.cpp and linking it to create the shared library
libFace.so) succeeds, you have to compile the file
Face_test.cpp and link the generated object file with your library to generate the executable. But the command
g++ Face_test.cpp -L. -lFace -o Face_test
did not contain any compiling options as in your previous calls. So just add these:
g++ -std=c++11 -O3 -I.. Face_test.cpp -L. -lFace -o Face_test
I don't know your setup so that it might be neccesary to add more options (e.g.
-I../dlib/image_processing
which should definitely avoid the error).