Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

static linking is somewhat different. you now have to add all those dependancy libs manually, that were conveniently linked to the dynamic so's before. also -- order matters !

pkg-config can't handle this. you could try to generate a makefile with cmake:

cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
set( OpenCV_STATIC ON )        ##### <--- need to add this !!
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )

or try to specify everything explicitly (extremely painful !):

g++ main.cpp  -L /usr/local/share/OpenCV/3rdparty/lib -lopencv_imgcodecs -lopencv_highgui -lopencv_imgproc -lopencv_core  <what_ever_gui_libs_you_need>   -littnotify -ljpeg -llibpng -llibtiff -llibwebp -lrt -ldl -lz -lpthread -o myprog

the gist here is: if lib A depends on lib B, the order must be: -lA -lB (and all the system libs go to the end of the list)