How to build opencv_java4100.dll of 50,478KB for Win64

Hi there,
I built OpenCV 4.10.0 from source files of opencv-4.10.0.zip and opencv_contrib-4.10.0.zip, however the size of generated opencv_java4100.dll for Win64 is 5,505KB. I see that the pre-built opencv_java4100.dll size is 50,478KB.

Visual Studio 2022 is used to compile on Windows 11. And JDK 17 for Java.
I used CMake and specified contrib modules directory for OPENCV_EXTRA_MODULES_PATH, no other settings was modified.
Then performed Batch Build of BUILD_ALL and INSTALL from Visual Studio. At the end of the build output, I got the following 2 lines.

========== Build: 334 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 2:34 pm and took 42:30.102 minutes ==========

The size of generated opencv_java4100.dll is 5,505KB. I would like to build 50,478KB file size of opencv_java4100.dll from the source files.
Would you tell what is wrong in the steps to build?

Thank you,

that’s somewhat expected. if you take a closer look, it also built single module dlls, like opencv_ccore4100.dll, opencv_imgproc4100.dll, etc; and if you sum up the sizes, you’ll get about the same num bytes.

nothing actually wrong with it, it’s all useable, only downside is, that those dlls need to be reachable from the PATH, so they can be hot-loaded from java at runtime.

you can avoid the problem by adding

BUILD_SHARED_LIBS=OFF

to the cmake flags, then cleanup the build folder & rerun cmake & make
(it’s even mentioned in the docs !)

p.s : since you include the contrib modules now, expect the size to double !

Thank you, berak!
I was not aware how BUILD_SHARED_LIB flag affects to the build exactly. Now I see differences in opencv_java4100.dll by changing the flag.