Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opencv.pc file does not include static dependencies #12597

Open
jeroen opened this issue Sep 20, 2018 · 0 comments
Open

opencv.pc file does not include static dependencies #12597

jeroen opened this issue Sep 20, 2018 · 0 comments

Comments

@jeroen
Copy link

jeroen commented Sep 20, 2018

It looks like cmake does not populate the @OPENCV_PC_LIBS_PRIVATE@ field in opencv.pc, at least on MacOS. I am using the homebrew build of opencv. The opencv.pc file looks like this:

prefix=/usr/local/Cellar/opencv/3.4.2
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 3.4.2
Libs: -L${exec_prefix}/lib -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_photo -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_dnn -lopencv_plot -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ml -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_flann -lopencv_xobjdetect -lopencv_imgcodecs -lopencv_objdetect -lopencv_xphoto -lopencv_imgproc -lopencv_core
Libs.private:
Cflags: -I${includedir_old} -I${includedir_new}

As we can see the Libs.private: does not declare the static dependencies and therefore static linking fails. In the case of homebrew I would expect something like this in opencv.pc:

Libs.private: -ltbb -lippicv -lippiw -littnotify -llibjpeg-turbo -llibwebp -lpng -ltiff
Requires.private: openexr libavdevice

Obviously this depends on the exact configuration, but generally speaking, Requires.private names the .pc files for external libs that opencv was built (if they have a pc file), and Libs.private lists the bundled 3rdparty libs, and also external libs that do not have a pc file.

As a workaround I use the following to get the proper static linking LIBS:

LIBS_OPENCV=$(pkg-config --libs --static opencv)
LIBS_EXTRA=$(pkg-config --libs --static openexr libavdevice)
LIBS_STATIC="-ltbb -lippicv -lippiw -littnotify -llibjpeg-turbo -llibwebp -lpng -ltiff"
LIBS="$LIBS_OPENCV $LIBS_STATIC $LIBS_EXTRA"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants