Ask Your Question

static compile application error

asked 2018-06-19 09:42:10 -0500

pranan gravatar image

I have compiled openCV 3.3.1 with static (BUILD_SHARED_LIBS off in cmake). Compile and install done successfully. Using this I compiled the following program. But it causes compilation errors, one line of which I have copied here (there are about 50 errors of similar kind). Request help. Thanks in advance.



Mat img = Mat::zeros(300, 300,CV_8UC3);

imshow("output", img);

cout <<"hello world" << endl;


libopencv_highgui331.a(window_w32.cpp.obj):window_w32.cpp:(.text$_ZL15icvRemoveWindowP8CvWindow+0x114)||undefined reference to `__imp_SelectObject'

edit retag flag offensive close merge delete


why on earth are a you trying with outdated 3.3.1 ?

berak gravatar imageberak ( 2018-06-19 10:32:30 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-06-19 10:37:31 -0500

berak gravatar image

with static linking, the order of libraries matters. e.g. anything, that depends on core has to go before that.

also, you now have to link against all needed 3rd party and system libs now.

last time i tried, it looked like this:

g++ my.cpp -I. -Ic:\p\opencv\build -Ic:\p\opencv\build\install\include -Lc:\p\opencv\build\install\x64\mingw\staticlib -lopencv_optflow340 -lopencv_bioinspired340 -lopencv_tracking340 -lopencv_plot340 -lopencv_datasets340 -lopencv_dnn340 -lopencv_face340 -lopencv_xfeatures2d340 -lopencv_features2d340 -lopencv_calib3d340 -lopencv_flann340 -lopencv_objdetect340 -lopencv_ml340 -lopencv_photo340 -lopencv_video340 -lopencv_videoio340 -lopencv_highgui340 -lopencv_imgcodecs340 -lopencv_ximgproc340 -lopencv_imgproc340 -lopencv_core340  -llibprotobuf -lkernel32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -lvfw32 -llibpng -llibjpeg -lopengl32 -lglu32 -luser32 -lz -lgcov -O3 -o my.cpp
edit flag offensive delete link more


thank you I will try that

pranan gravatar imagepranan ( 2018-06-19 11:29:03 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-06-19 09:42:10 -0500

Seen: 222 times

Last updated: Jun 19 '18