Ask Your Question
0

Static compilation OpenCV & Extra Module

asked 2018-09-27 06:32:31 -0500

cherault gravatar image

Hi all,

I would like to build OpenCV with a single Extra Module, to build a specific application on Linux and Windows. So, how can I achieve this crucial point for me ?

I am under Linux Debian with OpenCV-3.4, and I would like to build my application with an extra module to build a global executable program which works under linux and windows.

Thanks for your help and support.

Cheers,

edit retag flag offensive close merge delete

Comments

which contrib module is it ? (so we can look up the dependancies)

it's still pretty much the same receipe as here

to build static libs, you have to use: cmake -DBUILD_SHARED_LIBS=OFF

berak gravatar imageberak ( 2018-09-27 07:11:45 -0500 )edit
1

Hello Berak, Thanks for your answer. The module I need to add is the Bioinspired module. Do you think I can optimized the static compile using just the necessary of OpenCV modules or I need to do it with the entire OpenCV lib ?

Thank you

cherault gravatar imagecherault ( 2018-09-27 07:21:59 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-09-27 07:52:27 -0500

berak gravatar image

updated 2018-09-27 07:53:11 -0500

there is a BUILD_LIST option for cmake, where you can specify exactly the opencv modules you want / need. (comma seperated list)

looking at the bioinspired's cmakelists.txt we see, that we need at least: opencv_core

(though, no idea, what your program really does, i guess you still need some more, e.g. for loading images, gui, etc.)

i'd propose the following cmake options:

-DOPENCV_EXTRA_MODULES=/where/you/put/contrib/modules/bioinspired
-DBUILD_LIST=bioinspired,core,imgcodecs,imgproc,highgui
-DBUILD_SHARED_LIBS=OFF

but note, that linking your program later to static libs is much more difficult, than the dynamic case, because you

  • have to use the libs in dependancy order, e.g. anything dependant on core has to go before that in the list,
  • have to add all the nessecary system libs (that were conveniently linked already when using so's) , like -llibjpeg -lz -ldl now, those have to go to the end of the list


getting this right, might prove a bit painful, just saying...

edit flag offensive delete link more

Comments

Hi Berak,

Thanks a lot for your information, really useful. I will test your idea, and go back to you if I have some problems.

Regards,

cherault gravatar imagecherault ( 2018-09-28 00:12:51 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-09-27 06:32:31 -0500

Seen: 44 times

Last updated: Sep 27 '18