# OpenCV 4.9 Build for java

**URL:** <https://forum.opencv.org/t/opencv-4-9-build-for-java/18419>\
**Category:** Android/Java\
**Tags:** dnn, windows, build, cuda\
**Created:** [August 4, 2024, 1:10pm UTC](https://forum.opencv.org/t/opencv-4-9-build-for-java/18419 "2024-08-04T13:10:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheMightyWarrior](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@TheMightyWarrior](https://forum.opencv.org/u/TheMightyWarrior)\
**Post date:** [August 4, 2024, 1:10pm UTC](https://forum.opencv.org/t/opencv-4-9-build-for-java/18419/1 "2024-08-04T13:10:44Z")

</div>

Hi everyone. I have got some problems with building openCV 4.9 for java with cuda. I did it using CMake. When i finished building in built\bin\Release\ folder i got many different dll files instead of one opencv\_java490.dll or somthing like that. INSTALL (see downbelow) folder is empty. Also in configure output i see that in section java java is NO and i dont really understand that because in OpenCV modules to be build java presents it is not windows variable (JAVA\_HOME) aswell . What can i do to make it work? I am new in OpenCV and dont know a lot so ask for help.  
Configure output here:

```auto
CMake Warning (dev) at CMakeLists.txt:120 (enable_language):
  project() should be called prior to this enable_language() call.
This warning is for project developers. Use -Wno-dev to suppress it.

Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Windows-MSVC.cmake:539 (enable_language):
  project() should be called prior to this enable_language() call.
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Windows-MSVC.cmake:509 (__windows_compiler_msvc_enable_rc)
  C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Windows-MSVC-CXX.cmake:6 (__windows_compiler_msvc)
  C:/Program Files/CMake/share/cmake-3.30/Modules/CMakeCXXInformation.cmake:48 (include)
  CMakeLists.txt:120 (enable_language)
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Windows-MSVC.cmake:539 (enable_language):
  project() should be called prior to this enable_language() call.
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Windows-MSVC.cmake:509 (__windows_compiler_msvc_enable_rc)
  C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Windows-MSVC-C.cmake:5 (__windows_compiler_msvc)
  C:/Program Files/CMake/share/cmake-3.30/Modules/CMakeCInformation.cmake:48 (include)
  CMakeLists.txt:120 (enable_language)
This warning is for project developers. Use -Wno-dev to suppress it.

ocv_init_download: OpenCV source tree is not fetched as git repository. 3rdparty resources will be downloaded from github.com by default.
Detected processor: AMD64
CMake Warning at cmake/OpenCVDetectCXXCompiler.cmake:182 (message):
  OpenCV does not recognize MSVC_VERSION "1940". Cannot set OpenCV_RUNTIME
Call Stack (most recent call first):
  CMakeLists.txt:174 (include)

Can't detect runtime and/or arch
libjpeg-turbo: VERSION = 2.1.3, BUILD = opencv-4.9.0-libjpeg-turbo
libjpeg-turbo(SIMD): SIMD extensions disabled: could not find NASM compiler. Performance will suffer.
Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
OpenJPEG: VERSION = 2.5.0, BUILD = opencv-4.9.0-openjp2-2.5.0
OpenJPEG libraries will be built from sources: libopenjp2 (version "2.5.0")
found Intel IPP (ICV version): 2021.11.0 [2021.11.0]
at: C:/Files/OPENCV/build/3rdparty/ippicv/ippicv_win/icv
found Intel IPP Integration Wrappers sources: 2021.11.0
at: C:/Files/OPENCV/build/3rdparty/ippicv/ippicv_win/iw
NVCUVID: Header not found, WITH_NVCUVID requires Nvidia decoding library header C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4;C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4/include/nvcuvid.h
NVCUVENC: Header not found, WITH_NVCUVENC requires Nvidia encoding library header C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4;C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4/include/nvEncodeAPI.h
CUDA detected: 12.4
CUDA: Using CUDA_ARCH_BIN=8.6
CUDA: NVCC target flags -gencode;arch=compute_86,code=sm_86;-D_FORCE_INLINES;-gencode;arch=compute_90,code=compute_90
CUDA: MSVS generator is detected. Disabling CMake re-run checks (CMAKE_SUPPRESS_REGENERATION=ON). You need to run CMake manually if updates are required.
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find BLAS (missing: BLAS_LIBRARIES) 
Could NOT find LAPACK (missing: LAPACK_LIBRARIES) 
    Reason given by package: LAPACK could not be found because dependency BLAS could not be found.

Found apache ant: C:/Files/OPENCV/apache-ant-1.10.14/bin/ant.bat (1.10.14)
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
Module opencv_alphamat disabled because the following dependencies are not found: Eigen
freetype2: NO
harfbuzz: NO
Julia not found. Not compiling Julia Bindings. 
Module opencv_ovis disabled because OGRE3D was not found
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags
Tesseract: NO
Allocator metrics storage type: 'long long'
Excluding from source files list: <BUILD>/modules/core/test/test_intrin256.lasx.cpp
Excluding from source files list: modules/imgproc/src/imgwarp.lasx.cpp
Excluding from source files list: modules/imgproc/src/resize.lasx.cpp
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': C:/Files/OPENCV/opencv-4.9.0/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
Excluding from source files list: modules/dnn/src/layers/cpu_kernels/conv_winograd_f63.neon.cpp
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.rvv.cpp
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.lasx.cpp
Excluding from source files list: <BUILD>/modules/dnn/int8layers/layers_common.lasx.cpp
Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_block.neon.cpp
Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_block.neon_fp16.cpp
Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_depthwise.rvv.cpp
Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_depthwise.lasx.cpp
Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_winograd_f63.neon_fp16.cpp
Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/fast_gemm_kernels.neon.cpp
Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/fast_gemm_kernels.lasx.cpp
imgcodecs: OpenEXR codec is disabled in runtime. Details: https://github.com/opencv/opencv/issues/21326
CMake Warning at C:/Files/OPENCV/opencv_contrib-4.9.0/modules/cudacodec/CMakeLists.txt:26 (message):
  cudacodec::VideoReader requires Nvidia Video Codec SDK. Please resolve
  dependency or disable WITH_NVCUVID=OFF

CMake Warning at C:/Files/OPENCV/opencv_contrib-4.9.0/modules/cudacodec/CMakeLists.txt:30 (message):
  cudacodec::VideoWriter requires Nvidia Video Codec SDK. Please resolve
  dependency or disable WITH_NVCUVENC=OFF

highgui: using builtin backend: WIN32UI
rgbd: Eigen support is disabled. Eigen is Required for Posegraph optimization
Building with NVIDIA Optical Flow API 2.0
Found 'misc' Python modules from C:/Files/OPENCV/opencv-4.9.0/modules/python/package/extra_modules
Found 'mat_wrapper;utils' Python modules from C:/Files/OPENCV/opencv-4.9.0/modules/core/misc/python/package
Found 'gapi' Python modules from C:/Files/OPENCV/opencv-4.9.0/modules/gapi/misc/python/package

General configuration for OpenCV 4.9.0 =====================================
  Version control: unknown

  Extra modules:
    Location (extra): C:/Files/OPENCV/opencv_contrib-4.9.0/modules
    Version control (extra): unknown

  Platform:
    Timestamp: 2024-08-04T11:36:11Z
    Host: Windows 10.0.22631 AMD64
    CMake: 3.30.2
    CMake generator: Visual Studio 17 2022
    CMake build tool: C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe
    MSVC: 1940
    Configuration: Release

  CPU/HW features:
    Baseline: SSE SSE2 SSE3
      requested: SSE3
    Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (18 files): + SSSE3 SSE4_1
      SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (9 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (38 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX

  C/C++:
    Built as dynamic libs?: YES
    C++ standard: 11
    C++ Compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe (ver 19.40.33813.0)
    C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP /O2 /Ob2 /DNDEBUG 
    C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP /Zi /Ob0 /Od /RTC1 
    C Compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe
    C flags (Release): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /MP /O2 /Ob2 /DNDEBUG 
    C flags (Debug): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /MP /Zi /Ob0 /Od /RTC1 
    Linker flags (Release): /machine:x64 /INCREMENTAL:NO 
    Linker flags (Debug): /machine:x64 /debug /INCREMENTAL 
    ccache: NO
    Precompiled headers: NO
    Extra dependencies: cudart_static.lib nppc.lib nppial.lib nppicc.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib npps.lib cublas.lib cudnn.lib cufft.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4/lib/x64
    3rdparty dependencies:

  OpenCV modules:
    To be built: aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform java line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
    Disabled: world
    Disabled by dependency: -
    Unavailable: alphamat cannops cvv freetype hdf julia matlab ovis python2 python3 sfm viz
    Applications: tests perf_tests apps
    Documentation: NO
    Non-free algorithms: NO

  Windows RT support: NO

  GUI: WIN32UI
    Win32 UI: YES
    VTK support: NO

  Media I/O: 
    ZLib: build (ver 1.3)
    JPEG: build-libjpeg-turbo (ver 2.1.3-62)
      SIMD Support Request: YES
      SIMD Support: NO
    WEBP: build (ver encoder: 0x020f)
    PNG: build (ver 1.6.37)
    TIFF: build (ver 42 - 4.2.0)
    JPEG 2000: build (ver 2.5.0)
    OpenEXR: build (ver 2.3.0)
    HDR: YES
    SUNRASTER: YES
    PXM: YES
    PFM: YES

  Video I/O:
    DC1394: NO
    FFMPEG: YES (prebuilt binaries)
      avcodec: YES (58.134.100)
      avformat: YES (58.76.100)
      avutil: YES (56.70.100)
      swscale: YES (5.9.100)
      avresample: YES (4.0.0)
    GStreamer: NO
    DirectShow: YES
    Media Foundation: YES
      DXVA: YES

  Parallel framework: Concurrency

  Trace: YES (with Intel ITT)

  Other third-party libraries:
    Intel IPP: 2021.11.0 [2021.11.0]
           at: C:/Files/OPENCV/build/3rdparty/ippicv/ippicv_win/icv
    Intel IPP IW: sources (2021.11.0)
              at: C:/Files/OPENCV/build/3rdparty/ippicv/ippicv_win/iw
    Lapack: NO
    Eigen: NO
    Custom HAL: NO
    Protobuf: build (3.19.1)
    Flatbuffers: builtin/3rdparty (23.5.9)

  NVIDIA CUDA: YES (ver 12.4, CUFFT CUBLAS FAST_MATH)
    NVIDIA GPU arch: 86
    NVIDIA PTX archs: 90

  cuDNN: YES (ver 8.9.7)

  OpenCL: YES (NVD3D11)
    Include path: C:/Files/OPENCV/opencv-4.9.0/3rdparty/include/opencl/1.2
    Link libraries: Dynamic load

  Python (for build): C:/Users/Admin/AppData/Local/Programs/Python/Python312/python.exe

  Java:                          
    ant: C:/Files/OPENCV/apache-ant-1.10.14/bin/ant.bat (ver 1.10.14)
    Java: NO
    JNI: C:/Program Files/Java/jdk-22/include C:/Program Files/Java/jdk-22/include/win32 C:/Program Files/Java/jdk-22/include
    Java wrappers: YES (ANT)
    Java tests: YES

  Install to: C:/Files/OPENCV/install
-----------------------------------------------------------------

Configuring done (16.0s)

```

Also here is the whole folder if it will help

 ![Screenshot 2024-08-04 160819](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/3/3aed492138c1e54eed4af20222a78372173f6aa2.png)

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [August 5, 2024, 4:30am UTC](https://forum.opencv.org/t/opencv-4-9-build-for-java/18419/2 "2024-08-05T04:30:36Z")

</div>

> [@TheMightyWarrior](#):
>
> building openCV 4.9 for java with cuda

afaik, there is (still) no GPUMat support in the java api,  
however, you may use the dnn cuda backed, then.

> [@TheMightyWarrior](#):
>
> When i finished building in built\bin\Release\ folder i got many different dll files instead of one opencv\_java490.dll

please use the `BUILD_SHARED_LIBS=OFF` flag with cmake to avoid this

---

<div class="post-metadata">

**Author:** ![TheMightyWarrior](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@TheMightyWarrior](https://forum.opencv.org/u/TheMightyWarrior)\
**Post date:** [August 5, 2024, 5:43am UTC](https://forum.opencv.org/t/opencv-4-9-build-for-java/18419/3 "2024-08-05T05:43:31Z")

</div>

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![bysani2003](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/bysani2003/32/10895_2.png) [@bysani2003](https://forum.opencv.org/u/bysani2003)\
**Post date:** [August 5, 2024, 10:48am UTC](https://forum.opencv.org/t/opencv-4-9-build-for-java/18419/4 "2024-08-05T10:48:34Z")

</div>

```auto
cmake -DWITH_CUDA=ON -DWITH_JAVA=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install ..

```

USE THIS, IT MIGHT HELP
