Ask Your Question
0

order of -lopencv_core -lopencv_highgui -lopencv_photo -lopencv_videoio -lopencv_imgproc -lopencv_calib3

asked 2020-04-26 11:30:32 -0500

andrei186 gravatar image

http://gcc.gnu.org/onlinedocs/gcc/Lin... reads:

-llibrary -l library

It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, ‘foo.o -lz bar.o’ searches library ‘z’ after file foo.o but before bar.o. If bar.o refers to functions in ‘z’, those functions may not be loaded.

The shared libraries, for example libopencv-video, require other libraries and themselves are required by other libraries.

Does this mean that in the compile command their order ( -lopencv_core -lopencv_highgui -lopencv_photo -lopencv_videoio -lopencv_imgproc -lopencv_calib3) matters?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2020-04-28 10:35:54 -0500

berak gravatar image

as long as you're linking dynamic libs, the order does not matter at all.

quite a different picture with static libs, since you have to sort them by dependancy. you also need to explicitly link to all dependancies (like e.g. zlib) which were conveniently linked to the so's when building the libs.

so, if you have :

-lopencv_core -lopencv_imgcodecs -lz -lpng

core has to go after imgcodecs, which depends on png, which depends on zlib, so it must be:

-lopencv_imgcodecs -lopencv_core -lpng  -lz
edit flag offensive delete link more

Comments

Thank you.
This syntax does not allow .so or .a extentions. Does it mean that static and dynamic libs should not be in the same folder not to confuse the linker?

Also I read somewhere that lopencv_core is a root in sense that all other libs depend on it and therefore it should go first. Now I see I am wrong. Where can see the interconnections between the main OpenCV libs (-lopencv_imgcodecs -lopencv_core -lopencv_highgui -lopencv_photo -lopencv_videoio -lopencv_video -lopencv_imgproc -lopencv_calib3d)? I.e. which depends on which?

andrei186 gravatar imageandrei186 ( 2020-04-28 11:36:34 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-04-26 11:30:32 -0500

Seen: 70 times

Last updated: Apr 28