Compile static application
I want to make my openCV application portable somehow. So far i have compiled opencv with the BUILD_SHARED_LIBS=OFF command successfully, and the resulting folder containes the precious ".a" files. when i compile my application with the following command:
g++ -o atafut -std=c++11 -I /home/moritz/opencv/opencv-4.1.0-built/include/opencv4 --static -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio -O0 -g -pthread main.cpp
i get the errors
/usr/bin/ld: cannot find -lopencv_core
/usr/bin/ld: cannot find -lopencv_imgproc
/usr/bin/ld: cannot find -lopencv_highgui
/usr/bin/ld: cannot find -lopencv_imgcodecs
/usr/bin/ld: cannot find -lopencv_videoio
collect2: error: ld returned 1 exit status
when i leave out the --static flag, everything works fine, but my application is not portable.
I am a bit of a noob, so hopefully i am forgetting something obvious.
i find it hard to believe that, your library list is far from complete (all actual img codecs, zlib missing)
DID you build dynamic libs before ? (if not so, --static should have no effect at all)
Ok, i have gotten a bit further since. The reason it worked without static was that i also had the opencv package installed on my system that was dynamically compiled and therefore no use for this issue. I uninstalled this package and i always got the same error message with and without static. Next i added
-L /home/moritz/opencv/opencv-4.1.0-built/lib64
to the compile command and i also added this directory to my LD_LIBRARY_PATH variable. This changed my error message, YAY! The new error message of the gcc is huge and can be found here: https://pastebin.com/EYrGKqBe it basically complains about a huge number of undefined references any ideas how to proceed?please put your error msgs here, not on an external bin, where it will expire.
Here is as much of the error message as will fit in this comment section:
opencl_core.cpp:(.text._ZL15opencl_check_fni+0x1ba): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: /home/moritz/opencv/opencv-4.1.0-built/lib64/libopencv_core.a(arithm.dispatch.cpp.o): in function
cv::hal::add8u(unsigned char const*, unsigned long, unsigned char const*, unsigned long, unsigned char*, unsigned long, int, int, void*)': arithm.dispatch.cpp:(.text._ZN2cv3hal5add8uEPKhmS2_mPhmiiPv+0x89): undefined reference to
ippicviAdd_8u_C1RSfs' /usr/bin/ld: /home/moritz/opencv/o