C++ programs linked to OpenCV are very slow to load (at least 0.5 seconds on my system). I assume this is because of the size of the libraries that need to be loaded into memory. Is it possible to reduce the load time by limiting the libraries to only those which are essential for the program?
Here's a timing example:
$ cat a.cpp
int
main(int argc, char** argv) {
return 0;
}
$ g++ a.cpp
$ time for x in {0..100}; do ./a.out; done
real 0m0.442s
user 0m0.161s
sys 0m0.294s
$ g++ a.cpp $(pkg-config --cflags --libs opencv)
$ time for x in {0..100}; do ./a.out; done
real 0m54.962s
user 0m51.280s
sys 0m3.566s
Profiling was done on Debian 10 (linux kernel 4.19.0-6-amd64). The OpenCV library version used was 3.2.0 (pkg-config --modversion opencv
). Compilation was done with g++ 8.3.0.