DIPlib / diplib

Quantitative Image Analysis in C++, MATLAB and Python
https://diplib.org
Apache License 2.0
227 stars 49 forks source link

macOS make -j install error #29

Closed ajinkya933 closed 5 years ago

ajinkya933 commented 5 years ago

Component Select one or more of: DIPlib, CMake build scripts. I am following https://github.com/DIPlib/diplib

Describe the bug I am following the instructions on https://github.com/DIPlib/diplib/blob/master/INSTALL_MacOS.md I am having trouble in the Building session

when I type

make -j check:

[doctest] test cases: 68 | 68 passed | 0 failed | 0 skipped [doctest] assertions: 2139 | 2139 passed | 0 failed | [doctest] Status: SUCCESS! [100%] Built target check

but when I try to install using:

make -j install

I get something like this:

[ 95%] Building CXX object pydip/CMakeFiles/PyDIP_bin.dir/measurement.cpp.o [ 95%] Building CXX object pydip/CMakeFiles/PyDIP_bin.dir/morphology.cpp.o [ 96%] Building CXX object pydip/CMakeFiles/PyDIP_bin.dir/statistics.cpp.o [ 96%] Building CXX object pydip/CMakeFiles/PyDIP_bin.dir/pydip.cpp.o [ 96%] Building CXX object pydip/CMakeFiles/PyDIP_bin.dir/image.cpp.o [ 96%] Generating CMakeFiles/DIPjavaio_java.dir/java_class_filelist [ 97%] Creating Java archive DIPjavaio.jar In file included from /Users/ajinkyabobade/src/diplib/viewer/src/manager.cpp:22: /Users/ajinkyabobade/src/diplib/viewer/src/fg_font_data.h:360:5: warning: 'glPushClientAttrib' is deprecated: first deprecated in macOS 10.14 - OpenGL API deprecated. (Define GL_SILENCE_DEPRECATION to silence these warnings) [-Wdeprecated-declarations] glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT ); ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2624:13: note: 'glPushClientAttrib' has been explicitly marked deprecated here extern void glPushClientAttrib (GLbitfield mask) OPENGL_DEPRECATED(10.0, 10.14); ^ In file included from /Users/ajinkyabobade/src/diplib/viewer/src/manager.cpp:22: /Users/ajinkyabobade/src/diplib/viewer/src/fg_font_data.h:361:5: warning: 'glPixelStorei' is deprecated: first deprecated in macOS 10.14 - OpenGL API deprecated. (Define GL_SILENCE_DEPRECATION to silence these warnings) [-Wdeprecated-declarations] glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE );

I am attaching the complete report file so that you can get a better idea. report.txt How do I remove this error ?

System information:

wcaarls commented 5 years ago

The relevant error seems to be

/Users/ajinkyabobade/src/diplib/javaio/src/javaio.cpp:66:24: error: use of undeclared identifier 'JNI_VERSION_1_8' vm_args.version = JNI_VERSION_1_8;

Did you install JDK 1.8? (http://www.oracle.com/technetwork/java/javase/downloads/index.html). In theory, it shouldn't try to build JavaIO if not. Maybe it found the SDK but uses the wrong JNI version? Hopefully Cris should be able to help.

If you don't need JavaIO, you can configure with

cmake .. -DDIP_BUILD_JAVAIO=OFF

In any case, if would be a good idea to silence the OpenGL warnings by defining GL_SILENCE_DEPRECATION. I don't think it will be removed anytime soon. I'm a bit concerned about JNI being deprecated, though.

crisluengo commented 5 years ago

Yes, I received that error on MacOS when the version of JNI found by CMake was the one that comes installed by default, rather than the one that comes with JDK 1.8. You need to have JDK 1.8 installed, and add -DJAVA_HOME=<path to JDK 1.8> to your CMake command.

In the CMake output, you will see two lines, one about the version of Java found, and one about the version of JNI found. These two should match.

Or, as Wouter suggested, you can disable JavaIO. This one is useful because it allows you to read many, many microscopy image formats. But you might have no need for it.

The long list of warnings are related to OpenGL:

first deprecated in macOS 10.14 - OpenGL API deprecated.

I haven't upgraded to Mojave jet (still on 10.13), so hadn't seen these. Apple has deprecated OpenGL, wants everyone to use Metal instead (this is the MacOS-only graphics API, just like Windows has DirectX). I hope they don't remove OpenGL any time soon. In the meantime, I'll add the GL_SILENCE_DEPRECATION define to the compile options for MacOS.

ajinkya933 commented 5 years ago

I have java --version ==javac 11.0.1. Should I downgrade this to JDK 1.8

crisluengo commented 5 years ago

I don't think that is necessary, it looks like the JNI_VERSION_1_8 identifier should be defined in JDK 11.

I have seen this same error you are seeing. It happened when CMake found the JNI that comes with the JDK 1.6 that is shipped with MacOS, instead of the newer JDK that I installed from Oracle.

If you delete your CMakeCache.txt file (in the directory where you ran the cmake command), and run the cmake command again, you should see two lines in the output like these:

-- Found Java: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java (found suitable version "1.8.0.121", minimum required is "1.8") found components:  Development 
-- Found JNI: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/libjawt.dylib  

Yours will have 1.11 as the version found. But it is important that these two lines both point to the same JDK directory. When I had this error you are seeing, one of these two lines pointed to a JDK 1.6 directory. When I added -DJAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/ to the cmake command, these two lines matched, and the compilation error went away.

crisluengo commented 5 years ago

Sorry, I didn't mean to close this, happened when I pushed what I hope is a solution.

Could you please pull the latest changes in the master branch, and see if your error goes away?

I changed the CMake configuration script so that the JNI found is always the one that corresponds to the Java found. This should basically ensure that the two lines in the output of CMake that I referred to above always match. There should no longer be a need to add the -DJAVA_HOME=... argument to cmake unless CMake is not at all able to find Java.

Let me know if this fixes your issue!

ajinkya933 commented 5 years ago

Thank you for making the change on GitHub now it works !!