Build OpenCV 4.5.5 on mac mini m1 openjdk 17 - java

I'm trying to build OpenCV 4.5.5 on a mac mini m1 as follows
installed openjdk 17
created folder ~/build_opencv in user home and cd to it
from this folder call
cmake -DCMAKE_SYSTEM_PROCESSOR=arm64 \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DWITH_OPENJPEG=OFF \
-DWITH_IPP=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local/opencv \
-D JAVA_INCLUDE_PATH=$JAVA_HOME/include \
-D JAVA_AWT_LIBRARY=$JAVA_HOME/jre/lib/amd64/libawt.so \
-D JAVA_JVM_LIBRARY=$JAVA_HOME/jre/lib/arm/server/libjvm.so \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_java=ON \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=OFF \
-D BUILD_EXAMPLES=ON ../opencv-4.5.5
call
make -j7
Got a lot of warnings like
/Users/testuser/opencv-4.5.5/3rdparty/libpng/pngpriv.h:606:29: note: expanded from macro 'png_isaligned'
(((type)((const char*)ptr-(const char*)0) & \
^~~~~~~~~~~~~~~
/Users/testuser/opencv-4.5.5/3rdparty/libpng/pngrutil.c:3563:23: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
png_isaligned(sp, png_uint_32) &&
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/testuser/opencv-4.5.5/3rdparty/libpng/pngpriv.h:606:29: note: expanded from macro 'png_isaligned'
(((type)((const char*)ptr-(const char*)0) & \
^~~~~~~~~~~~~~~
/Users/testuser/opencv-4.5.5/3rdparty/libpng/pngrutil.c:4622:34: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
int extra = (int)((temp - (png_bytep)0) & 0x0f);
^ ~~~~~~~~~~~~
/Users/user/opencv-4.5.5/3rdparty/libpng/pngrutil.c:4626:30: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
extra = (int)((temp - (png_bytep)0) & 0x0f);
and final message
[ 71%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/python/gpythonbackend.cpp.o
[ 71%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/utils/itt.cpp.o
[ 71%] Linking CXX shared library ../../lib/libopencv_gapi.dylib
[ 71%] Built target opencv_gapi
make: *** [all] Error 2
Also tried openjdk 15 and 18 but led to same result.
Any ideas to fix this would be appreciated.

Related

Error building openJDK 11 with devkit: Unknown base OS Fedora

I need to build the following openJDK
git clone --depth 1 --branch jdk-11+28 https://github.com/openjdk/jdk.git
For that I run:
cd make/devkit
make TARGETS="aarch64-linux-gnu" BASE_OS=Fedora BASE_OS_VERSION=21 &>build.log
And got following error
Building on platform x86_64-unknown-linux-gnu
host_platforms x86_64-unknown-linux-gnu
target_platforms x86_64-unknown-linux-gnu
find: ‘/media/katya/e947f05e-bd8f-4647-bbdd-0df608faa788/openjdk11/jdk/build/devkit/result/x86_64-unknown-linux-gnu’: No such file or directory
Building compilers for x86_64-unknown-linux-gnu
Targets: x86_64-unknown-linux-gnu
for p in x86_64-unknown-linux-gnu ; do \
make -f Tools.gmk download-rpms HOST=x86_64-unknown-linux-gnu BUILD=x86_64-unknown-linux-gnu RESULT=/media/katya/e947f05e-bd8f-4647-bbdd-0df608faa788/openjdk11/jdk/build/devkit/result PREFIX=/media/katya/e947f05e-bd8f-4647-bbdd-0df608faa788/openjdk11/jdk/build/devkit/result/x86_64-unknown-linux-gnu OUTPUT_ROOT=/media/katya/e947f05e-bd8f-4647-bbdd-0df608faa788/openjdk11/jdk/build/devkit TARGET=$p && \
make -f Tools.gmk all HOST=x86_64-unknown-linux-gnu BUILD=x86_64-unknown-linux-gnu RESULT=/media/katya/e947f05e-bd8f-4647-bbdd-0df608faa788/openjdk11/jdk/build/devkit/result PREFIX=/media/katya/e947f05e-bd8f-4647-bbdd-0df608faa788/openjdk11/jdk/build/devkit/result/x86_64-unknown-linux-gnu OUTPUT_ROOT=/media/katya/e947f05e-bd8f-4647-bbdd-0df608faa788/openjdk11/jdk/build/devkit \
TARGET=$p || exit 1 ; \
done
make[1]: Entering directory '/media/katya/e947f05e-bd8f-4647-bbdd-0df608faa788/openjdk11/jdk/make/devkit'
TARGET=x86_64-unknown-linux-gnu
HOST=x86_64-unknown-linux-gnu
BUILD=x86_64-unknown-linux-gnu
ARCH=x86_64
Tools.gmk:66: *** Unknown base OS Fedora. Stop.
make[1]: Leaving directory '/media/katya/e947f05e-bd8f-4647-bbdd-0df608faa788/openjdk11/jdk/make/devkit'
Makefile:86: recipe for target 'x86_64-unknown-linux-gnu' failed
make: *** [x86_64-unknown-linux-gnu] Error 1
Host OS is Ubuntu 16.04.7 LTS (Xenial Xerus). Please tell me what am I doing wrong?
Where can I submit a bug report about openjdk11, or discuss this issue?

OpenJDK cross compilation: failed unable to make target

I need to cross-compile this fork of openJDK https://gitlab.com/gosjava/11/openjdk/-/tree/master/ on host system Kali Linux 2021.3 for target "aarch64-linux-gnu"
As described here https://gitlab.com/gosjava/11/openjdk/-/blob/master/doc/building.md#cross-compiling-the-easy-way-with-openjdk-devkits
And it fails with error:
┌──(katya㉿kali)-[~/work/prostor/openjdk]
└─$ cd make/devkit
┌──(katya㉿kali)-[~/…/prostor/openjdk/make/devkit]
└─$ make TARGETS="aarch64-linux-gnu"
Building on platform unknown-linux-gnu
host_platforms unknown-linux-gnu
target_platforms aarch64-linux-gnu
find: ‘/home/katya/work/prostor/openjdk/build/devkit/result/unknown-linux-gnu-to-aarch64-linux-gnu’: No such file or directory
Building compilers for unknown-linux-gnu
Targets: aarch64-linux-gnu
for p in aarch64-linux-gnu; do \
make -f Tools.gmk download-rpms HOST=unknown-linux-gnu BUILD=unknown-linux-gnu RESULT=/home/katya/work/prostor/openjdk/build/devkit/result OUTPUT_ROOT=/home/katya/work/prostor/openjdk/build/devkit \
TARGET=$p PREFIX=/home/katya/work/prostor/openjdk/build/devkit/result/unknown-linux-gnu-to-$p && \
make -f Tools.gmk all HOST=unknown-linux-gnu BUILD=unknown-linux-gnu RESULT=/home/katya/work/prostor/openjdk/build/devkit/result OUTPUT_ROOT=/home/katya/work/prostor/openjdk/build/devkit \
TARGET=$p PREFIX=/home/katya/work/prostor/openjdk/build/devkit/result/unknown-linux-gnu-to-$p && \
make -f Tools.gmk ccache HOST=unknown-linux-gnu BUILD=unknown-linux-gnu RESULT=/home/katya/work/prostor/openjdk/build/devkit/result OUTPUT_ROOT=/home/katya/work/prostor/openjdk/build/devkit \
TARGET=unknown-linux-gnu PREFIX=/home/katya/work/prostor/openjdk/build/devkit/result/unknown-linux-gnu-to-$p BUILDDIR=/home/katya/work/prostor/openjdk/build/devkit/unknown-linux-gnu/$p || exit 1 ; \
done
make[1]: Entering directory '/home/katya/work/prostor/openjdk/make/devkit'
TARGET=aarch64-linux-gnu
HOST=unknown-linux-gnu
BUILD=unknown-linux-gnu
ARCH=aarch64
Tools.gmk:75: *** Unknown base OS . Stop.
make[1]: Leaving directory '/home/katya/work/prostor/openjdk/make/devkit'
make: *** [Makefile:90: unknown-linux-gnu] Error 1
Why? The command make TARGETS="aarch64-linux-gnu" BASE_OS=OLE6 also fails
Tools.gmk:75: *** Unknown base OS OLE6. Stop.
make[1]: Leaving directory '/home/katya/work/prostor/openjdk/make/devkit'
make: *** [Makefile:90: unknown-linux-gnu] Error 1
What is wrong? I follow documentation, but ...

How to add shortcut to Windows app from jpackage+wix?

I got a script (just a simplified excerpt for brevity) to build and package my app, but it boils down to generating WiX installer with:
jpackage \
--type msi \
--dest "$(cygpath -w "${base[build:dist]}")" \
--name "${appDisplayName}" \
--app-version "${version}" \
--app-image "$(cygpath -w "${base[build:app]}")" \
--license-file "$(cygpath -w resources/app/legal/LICENSE)" \
--vendor "${vendor}" \
--verbose \
--temp 'W:\_tmp_' \
--win-shortcut;
It fails with enigmatic: Command [light.exe, (...)] in (...) exited with 94 code. Which I found is about unresolved reference and particularly a reference to a shortcut icon: ...\config\bundle.wxf(10) : error LGHT0094 : Unresolved reference to symbol 'Icon:icon1798580986' in section 'Fragment:'.
When I examined generated WiX XML, I found this:
<?xml version="1.0" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Fragment>
...
<DirectoryRef Id="DesktopFolder">
<Component Win64="yes" Id="cshortcut9906e12cdacb303ebb5e48c888cf6949" Guid="{9906e12c-dacb-303e-bb5e-48c888cf6949}">
...
<Shortcut Id="shortcut9906e12cdacb303ebb5e48c888cf6949" Name="..." WorkingDirectory="INSTALLDIR" Advertise="no" IconIndex="0" Target="[#filed2065cdc42e13
55f8bdbbefc93d540f3]" Icon="icon1798580986"></Shortcut>
</Component>
</DirectoryRef>
...
</Wix>
And indeed there's this "icon1798580986" value, which does not tell me anything and even WiX is lost here (after reading this this https://stackoverflow.com/a/21019152/2024692 I checked and confirmed that I actually do have WixUIExtension.dll in WiX bin folder).
When I remove --win-shortcut option, then MSI installer is generated, but unfortunately w/o shortcut icon on the desktop (the app has it's proper icons, thou, as I generated application image with --icon switch and with --resource-dir pointing to a.o. app icons).
As you probably guessed, this is called from Cygwin, so sometimes it needs fiddling with paths, especially when one calls Windows executables (hence these cygpath things).
Well, I wasn't able to find any constructive approaches how to simply allow my Java application packed with jpackage (from both JDK-14/15 EA with no success) to have nice shortcut icon after it gets installed. Does anyone knows how to fix this? Thanks in advance.
its easier to do with a gradle plugin
You need to set the proper icon file path and have a valid .ico file. This is how I did it:
jlink {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'PDF Decorator'
jvmArgs = ['-Djdk.gtk.version=2'] // required due to a bug in Java: https://github.com/javafxports/openjdk-jfx/issues/175
}
jpackage {
installerOptions = [
'--description', project.description,
'--copyright', 'Copyrigth 2015-2019 WALCZAK.IT'
]
installerType = project.findProperty('installerType') // we will pass this from the command line (example: -PinstallerType=msi)
if (installerType == 'msi') {
imageOptions += ['--icon', 'src/main/resources/pdfdecorator/gui/icon.ico']
installerOptions += [
'--win-per-user-install', '--win-dir-chooser',
'--win-menu', '--win-shortcut'
]
}
if (installerType == 'pkg') {
imageOptions += ['--icon', 'src/main/resources/pdfdecorator/gui/icon.icns']
}
if (installerType in ['deb', 'rpm']) {
imageOptions += ['--icon', 'src/main/resources/pdfdecorator/gui/icon_256x256.png']
installerOptions += [
'--linux-menu-group', 'Office',
'--linux-shortcut'
]
}
if (installerType == 'deb') {
installerOptions += [
'--linux-deb-maintainer', 'office#walczak.it'
]
}
if (installerType == 'rpm') {
installerOptions += [
'--linux-rpm-license-type', 'GPLv3'
]
}
}
}
Here's an article how to build an app image using OpenJDK 11 and using OpenJDK 14 with jpackage only for building the installer / package: https://walczak.it/blog/distributing-javafx-desktop-applications-without-requiring-jvm-using-jlink-and-jpackage
You just had the pleasure given by convention over configuration
When using jpackage --app-image and --win-shorcut parameters then jpackage expect to find the executable and the icon at the root of app-image directory to create the shortcut. The executable and the icon must have the same name as the one provided using the --name parameter.
In your case jpackage expects:
$(cygpath -w "${base[build:app]}")\${appDisplayName}.exe
$(cygpath -w "${base[build:app]}")\${appDisplayName}.ico
to exists to be able to create the shortcut.
If error 94 happens without --win-shortcut
This might actually be a problem relating to the --app-image parameter given to jpackage! An indicator for that is the warning that the app-image wasn't created by jpackage.
If your destination parameter when creating the app-image looks like --dest target/app-image, then you have to use --app-image target/app-image/myapp when creating the installer. Using --app-image target/app-image results in this error. A minor oversight that can create a lot of head-scratching because of the cryptic message.
This seems to happen for the reason #Mumrah81 gave:
[...] jpackage expect to find the executable and the icon at the root of app-image directory to create the shortcut.

CrossCompile jrxtx with yocto

I'm trying to crosscompile jrxtx library (https://github.com/openmuc/jrxtx) using a yocto toolchain but it fails.
first
source /opt/poky/environment-setup-cortexa8t2hf-vfp-neon-poky-linux-gnueabi
then
cd /home/peppe/projects/rxtx/jrxtx/native && ./BUILD.sh
I had to hand modify config.status to remove some errors on mv and rm, nevertheless i get
/bin/bash /home/peppe/projects/rxtx/jrxtx/native/libtool --mode=link arm-poky-linux-gnueabi-gcc -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/opt/poky/sysroots/cortexa8t2hf-vfp-neon-poky-linux-gnueabi -O2 -pipe -g -feliminate-unused-debug-types -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lpthread -release 2.2pre1 -o librxtxSerial.la -rpath /usr/lib/jvm/java-11-openjdk-amd64/jre/lib/amd64 /home/peppe/projects/rxtx/jrxtx/native/x86_64-unknown-linux-gnu/SerialImp.lo; \
fi; \
)
/bin/bash: line 2: cd: x86_64-unknown-linux-gnu: No such file or directory
/bin/bash: /home/peppe/projects/rxtx/jrxtx/native/libtool: No such file or directory
/bin/bash: /home/peppe/projects/rxtx/jrxtx/native/libtool: No such file or directory
/bin/bash: /home/peppe/projects/rxtx/jrxtx/native/libtool: No such file or directory
make: *** [Makefile:756: x86_64-unknown-linux-gnu/librxtxSerial.la] Error 127
Even it it seems to launch the correct compiler arm-poky-linux-gnueabi-gcc it tries to cd into x86_64-unknown-linux-gnu and obviously things gets mad...

object com.github.nscala_time.time.Imports not found error?

I used package com.github.nscala_time.time.Imports in code and I m running the code using spark.
Here is my stream.sh file:
#!/bin/bash
JARS_HOME=$HOME/spark-job/lib
JARS=$JARS_HOME/job-server-api_2.10-0.6.0.jar,$JARS_HOME/httpmime-4.4.1.jar,$JARS_HOME/noggit-0.6.jar,$JARS_HOME/nscala-time_2.10-2.0.0.jar
export SPARK_IP=`ifconfig | grep eth0 -1 | grep -i inet | awk '{ print $2 }' | cut -d':' -f2`
APP_JAR=$JARS_HOME/spark-jobs-tests.jar
export SPARK_LOCAL_IP=$SPARK_IP
dse spark-submit --conf "spark.cassandra.input.consistency.level=LOCAL_QUORUM" \
--total-executor-cores 2 \
--jars=$JARS \
--class "my file classpath" $APP_JAR "$1" --files $1
I have set $JARS_HOME/nscala-time_2.10-2.0.0.jar in .sh then still getting following error:
Exception in thread "main" scala.reflect.internal.MissingRequirementError: object com.github.nscala_time.time.Imports not found.
at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:16)
at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:17)
at scala.reflect.internal.Mirrors$RootsBase.ensureModuleSymbol(Mirrors.scala:126)
at scala.reflect.internal.Mirrors$RootsBase.staticModule(Mirrors.scala:161)
at scala.reflect.internal.Mirrors$RootsBase.staticModule(Mirrors.scala:21)
How to resolve this??

Categories

Resources