# Libopencv\_java.so & Cross-targeting

**URL:** https://forum.opencv.org/t/libopencv-java-so-cross-targeting/12931
**Category:** Android/Java
**Tags:** arm, build
**Created:** [April 24, 2023, 7:17pm UTC](https://forum.opencv.org/t/libopencv-java-so-cross-targeting/12931 "2023-04-24T19:17:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![icebeing](https://avatars.discourse-cdn.com/v4/letter/i/dec6dc/32.png) [@icebeing](https://forum.opencv.org/u/icebeing)
#### Post date: [April 24, 2023, 7:17pm UTC](https://forum.opencv.org/t/libopencv-java-so-cross-targeting/12931/1 "2023-04-24T19:17:07Z")

</div>

So I’m looking to build in libopencv\_java.so for the following cross-target: arm64-v8a  
What I’m a little puzzled about, is if this library contains ALL of opencv?

In my regular x86\_64 build, I have this Makefile line defined:  
LIBS += -lopencv\_core -lopencv\_imgproc -lopencv\_highgui -lopencv\_imgcodecs

Am I going to get equivalent functionality if I just do  
LIBS += -lopencv\_java

Thanks, Charles.

NOTE: my Native build has nothing to do with JNI/Java. Will this lib still work?

---

<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: [April 25, 2023, 7:24am UTC](https://forum.opencv.org/t/libopencv-java-so-cross-targeting/12931/2 "2023-04-25T07:24:53Z")

</div>

> [@icebeing](#):
>
> In my regular x86\_64 build, I have this Makefile line defined:  
> LIBS += -lopencv\_core -lopencv\_imgproc -lopencv\_highgui -lopencv\_imgcodecs

wait, this is to actually _build_`libopencv_java.so`, no ?  
(sounds a bit, like you’re confusing input / output…)

> [@icebeing](#):
>
> What I’m a little puzzled about, is if this library contains ALL of opencv?

if you build with BUILD\_SHARED\_LIBS=OFF (cmake), – YES.  
if you dont, libopencv\_java.so` will depend on other opencv so’s at runtime (core, imgproc, etc) , which contain the actual code

btw, you cannot use the highgui module from java, so skip that from the build  
(there’s a plain java ‘mock’ replacement in the java code)

---

<div class="post-metadata">

### Author: ![icebeing](https://avatars.discourse-cdn.com/v4/letter/i/dec6dc/32.png) [@icebeing](https://forum.opencv.org/u/icebeing)
#### Post date: [April 25, 2023, 1:37pm UTC](https://forum.opencv.org/t/libopencv-java-so-cross-targeting/12931/3 "2023-04-25T13:37:22Z")

</div>

No, it’s not to build libopencv\_java.so. I have downloaded a complete tree of pre-compiled binaries of libopencv\*.{so/a} for different mobile architectures, from the opencv site. One of them (arm64-v8a) is of interest to me.

I’m not using Java to integrate with opencv. I’m doing a true Native compilation build (Makefiles).

I don’t suppose you can point me to instructions on how to build opencv for Android, from the source?

Thanks, Charles.

---

<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: [April 26, 2023, 4:43am UTC](https://forum.opencv.org/t/libopencv-java-so-cross-targeting/12931/4 "2023-04-26T04:43:39Z")

</div>

apologies, seems i entirely missed, what you’re trying to do ;(

some (outdated) [links are here](https://docs.opencv.org/4.x/df/d65/tutorial_table_of_content_introduction.html)

receipe for (java based) [sdk is here](https://github.com/opencv/opencv/tree/4.x/platforms/android)

in the end, i cannot answer your question  
(rephrased: “can i use libopencv\_java.so for plain c++ dev ?”, right ?)

---

<div class="post-metadata">

### Author: ![icebeing](https://avatars.discourse-cdn.com/v4/letter/i/dec6dc/32.png) [@icebeing](https://forum.opencv.org/u/icebeing)
#### Post date: [April 26, 2023, 5:51am UTC](https://forum.opencv.org/t/libopencv-java-so-cross-targeting/12931/5 "2023-04-26T05:51:44Z")

</div>

Hi Berak -

That’s another way to phrase the question, but yes. As it happens, I was able to cross-link this lib with my arm64-v8a toolchain, for some small unit-tests that I’ve made. I’ll let you know if the UT’s end up working on my android platform.

Cheers, charles.
