It is possible to compile OpenVINO as a static library. However, it seems to work only with the CPU. According to github site https://github.com/openvinotoolkit/openvino/wiki/StaticLibraries, the GPU is not supported.
Here are the steps to compile OpenVINO in static with CPU only support. This works with Linux.
Get the source code from GitHub, along with the submodules:
git clone https://github.com/openvinotoolkit/openvino.git
cd openvino
git submodule update --init --recursive
chmod +x install_build_dependencies.sh
./install_build_dependencies.sh
mkdir build && cd build
Use cmake to specify the flags. For this basic example, only CPU is turned ON (ENABLE_INTEL_CPU=ON) and we compile with static libs (BUILD_SHARED_LIBS=OFF)
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_INTEL_MYRIAD_COMMON=OFF -DENABLE_INTEL_CPU=ON -DENABLE_INTEL_GPU=OFF -DENABLE_INTEL_GNA=OFF DENABLE_INTEL_MYRIAD=OFF -DENABLE_TEMPLATE=OFF -DENABLE_HETERO=OFF -DENABLE_MULTI=OFF -DENABLE_AUTO=OFF -DENABLE_AUTO_BATCH=OFF -DENABLE_OV_ONNX_FRONTEND=OFF -DENABLE_OV_PADDLE_FRONTEND=OFF -DENABLE_OV_TF_FRONTEND=OFF -DENABLE_IR_V7_READER=OFF -DENABLE_GAPI_PREPROCESSING=OFF -DENABLE_OV_IR_FRONTEND=ON -DENABLE_SAMPLES=OFF -DENABLE_SYSTEM_TBB=OFF -DENABLE_CLDNN=OFF -DENABLE_TBBBIND_2_5=OFF -DENABLE_OPENCV=OFF -DTHREADING=SEQ -DBUILD_SHARED_LIBS=OFF ..
Now, let’s compile and install the libs:
make --jobs=$(nproc --all)
sudo make install
At this point, the libs will be installed in /usr/local/runtime/lib/intel64
Here’s the command to compile and link a simple helloworld.cpp:
g++ helloworld.cpp -I/usr/local/runtime/include/ -I/usr/local/runtime/include/ie/ -Wl,--whole-archive /usr/local/runtime/lib/intel64/libopenvino.a /usr/local/runtime/lib/intel64/libutil.a /usr/local/runtime/lib/intel64/libpugixml.a /usr/local/runtime/lib/intel64/libopenvino_intel_cpu_plugin.a /usr/local/runtime/lib/intel64/libov_shape_inference.a /usr/local/runtime/lib/intel64/libade.a /usr/local/runtime/lib/intel64/libdnnl.a /usr/local/runtime/lib/intel64/libfluid.a /usr/local/runtime/lib/intel64/libinference_engine_snippets.a /usr/local/runtime/lib/intel64/libitt.a /usr/local/runtime/lib/intel64/libnlohmann_json_schema_validator.a /usr/local/runtime/lib/intel64/libopenvino_c.a /usr/local/runtime/lib/intel64/libngraph_reference.a /usr/local/runtime/lib/intel64/libngraph_builders.a /usr/local/runtime/lib/intel64/libopenvino_ir_frontend.a -Wl,--no-whole-archive -ldl -lpthread -o helloworld