Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dcm2jpg not working on MacOS M1 #1084

Closed
LetsMelon opened this issue Dec 19, 2021 · 8 comments
Closed

dcm2jpg not working on MacOS M1 #1084

LetsMelon opened this issue Dec 19, 2021 · 8 comments
Assignees
Labels
Milestone

Comments

@LetsMelon
Copy link

dcm2jpg can't download libopencv_java.jnilib on MacOS aarch64.

To Reproduce
Steps to reproduce the behavior:

  1. Use a M1-Chip (M1, M1 Pro or M1 Max)
  2. Download and install dcm4che3 toolset from sourceforge
  3. Execute dcm2jpg (eg.: dcm2jpg --help)
  4. See error message

Expected behavior
Terminal output:

$ dcm2jpg --help
/dcm4che/lib/macosx-aarch64/libopencv_java.jnilib is missing. 
Try to download https://github.com/nroduit/mvn-repo/raw/master/org/weasis/thirdparty/org/opencv/libopencv_java/4.5.3-dcm/libopencv_java-4.5.3-dcm-macosx-aarch64.jnilib
--2021-12-19 11:41:13--  https://github.com/nroduit/mvn-repo/raw/master/org/weasis/thirdparty/org/opencv/libopencv_java/4.5.3-dcm/libopencv_java-4.5.3-dcm-macosx-aarch64.jnilib
404 Not Found

Cannot download the native library related to the architecture macosx-aarch64, try it manually

Desktop

  • OS: MacOs
  • Prozesor: M1 Pro
  • Version: 5.25.0

Additional context
opencv/libopencv_java/4.5.3-dcm

@nroduit
Copy link
Member

nroduit commented Dec 20, 2021

Unfortunately, there is no way to automate the build without having Mac OS + hardware. I'm waiting for a solution from Github because for the moment I have neither hardware M1 nor the will to deal with this build manually.

However I guess it is possible to use a version of Java x86 with Rosetta.

@LetsMelon
Copy link
Author

I tried to use the version for mac os x86 (libopencv_java-4.5.3-dcm-macosx-x86-64.jnilib) but then I have an java.lang.UnsatisfiedLinkError-Error.

Native OpenCV library has been found in /dcm4che/lib/macosx-aarch64/libopencv_java.jnilib
11:49:27,386 DEBUG - Decompressor: org.dcm4che3.opencv.NativeImageReader
11:49:27,387 DEBUG - Start decompressing frame #1
Exception in thread "main" java.lang.UnsatisfiedLinkError: /dcm4che/lib/macosx-aarch64/libopencv_java.jnilib: dlopen(/dcm4che/lib/macosx-aarch64/libopencv_java.jnilib, 0x0001): tried: '/dcm4che/lib/macosx-aarch64/libopencv_java.jnilib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libopencv_java.jnilib' (no such file)
	at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
	at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:384)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:228)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:170)
	at java.base/jdk.internal.loader.NativeLibraries.findFromPaths(NativeLibraries.java:317)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:283)
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2422)
	at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
	at java.base/java.lang.System.loadLibrary(System.java:1989)
	at org.opencv.osgi.OpenCVNativeLoader.init(OpenCVNativeLoader.java:17)
	at org.dcm4che3.opencv.StreamSegment.<clinit>(StreamSegment.java:76)
	at org.dcm4che3.opencv.NativeImageReader.getNativeImage(NativeImageReader.java:260)
	at org.dcm4che3.opencv.NativeImageReader.read(NativeImageReader.java:251)
	at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.read(DicomImageReader.java:458)
	at org.dcm4che3.tool.dcm2jpg.Dcm2Jpg.readImageFromDicomInputStream(Dcm2Jpg.java:438)
	at org.dcm4che3.tool.dcm2jpg.Dcm2Jpg.convert(Dcm2Jpg.java:425)
	at org.dcm4che3.tool.dcm2jpg.Dcm2Jpg.mconvert(Dcm2Jpg.java:412)
	at org.dcm4che3.tool.dcm2jpg.Dcm2Jpg.main(Dcm2Jpg.java:381)

@LetsMelon
Copy link
Author

Unfortunately, there is no way to automate the build without having Mac OS + hardware. I'm waiting for a solution from Github because for the moment I have neither hardware M1 nor the will to deal with this build manually.

How can I build them myself?

@nroduit
Copy link
Member

nroduit commented Dec 20, 2021

I meant using a JDK with an x86 architecture with export JAVA_HOME=jdk-path

The sources of this library are not yet publicly distributed.

@LetsMelon
Copy link
Author

When I change JAVA_HOME to a java mac os jdk (openjdk17.0.1)

I have this error:

/dcm4che/bin/dcm2jpg: line 59: /jdk-17.0.1.jdk/bin/java: No such file or directory
/dcm4che/lib//libopencv_java.so is missing. 
Try to download https://github.com/nroduit/mvn-repo/raw/master/org/weasis/thirdparty/org/opencv/libopencv_java/4.5.3-dcm/libopencv_java-4.5.3-dcm-.so
--2021-12-20 12:22:59--  https://github.com/nroduit/mvn-repo/raw/master/org/weasis/thirdparty/org/opencv/libopencv_java/4.5.3-dcm/libopencv_java-4.5.3-dcm-.so
404: Not Found.

Cannot download the native library related to the architecture , try it manually.

@nroduit
Copy link
Member

nroduit commented Dec 20, 2021

I will be testing this soon as I am not familiar with how Rosetta works.

I need a little more time to prepare a compiled version under M1. I will post here as soon as I have something.

@LetsMelon
Copy link
Author

Ok thanks!

@nroduit
Copy link
Member

nroduit commented Dec 22, 2021

I just checked with openjdk 17-x86 and it works. You need to open a terminal with option "Rosetta", see https://www.courier.com/blog/tips-and-tricks-to-setup-your-apple-m1-for-development/

Another issue, the native lib is not signed in this dcm4che package, so you need to deactivate gatekeeper temporarly.

@dcm4che dcm4che locked and limited conversation to collaborators Dec 22, 2021
@gunterze gunterze converted this issue into discussion #1089 Dec 22, 2021
@gunterze gunterze added this to the 5.25.2 milestone Feb 14, 2022
@gunterze gunterze added bug and removed improvement labels Feb 14, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

3 participants