imagej / imagej-launcher

The ImageJ native launcher
https://imagej.net/learn/launcher
BSD 2-Clause "Simplified" License
21 stars 23 forks source link

Instructions for building on Window #43

Closed jpsacha closed 8 years ago

jpsacha commented 8 years ago

Please provide prerequisites and instructions for building imagej-launcher on Windows 10.

ctrueden commented 8 years ago

No one on the LOCI ImageJ team has ever tried building on Windows 10. If you get it working, feel free to contribute some instructions on how to do so, via a pull request.

For anyone else finding this issue: @jpsacha also posted this question on the ImageJ forum.

stelfrich commented 8 years ago

I don't have access to the computer I did this on until later today. When I am able to retrace my steps, I'll post a short guide here and cross-post in the forum.

stelfrich commented 8 years ago
  1. Install Java 8 SDK (with public JRE)
  2. Set JAVA_HOME (default C:\Program Files\Java\jdk1.8.0_92)
  3. Install MinGW with following meta packages:
    • mingw-developer-tools
    • mingw32-base
    • mingw32-gcc-g++
    • msys-base
  4. Follow description at to setup fstab (http://www.mingw.org/wiki/Getting_Started#toc2)
  5. Install Maven3 (also set PATH)
  6. Start C:\MinGW\msys\1.0\msys.bat
  7. Clone https://github.com/imagej/imagej-launcher/tree/fix-win10-sleep
  8. Go to source folder
    • cd /c/Users/test/imagej-launcher/
  9. Execute
    • mvn -Pcopy-launchers -Dos.arch=x86 install (for 32-bit)
    • mvn -Pcopy-launchers -Dos.arch=amd64 install (for 64-bit)

@jpsacha Could you check if that works for you (on 64-bit I assume), please?

ctrueden commented 8 years ago

@stelfrich Thank you very much for taking the time to write this up!

stelfrich commented 8 years ago

@ctrueden Should I open a PR for the fix-win10-sleep branch? We could keep that PR open until the LOCI VM is up again..

ctrueden commented 8 years ago

It's true that that sleep logic was added a very long time ago. But are you sure it is safe to delete?

jpsacha commented 8 years ago

@stelfrich Thanks for documenting the steps. It mostly worked. It may need a tweak to pom.xml for copying . I already had quite similar setup, I just modified fstab as described.

Maven first reports something that look like an "error":

[ERROR] In file included from D:\src\imagej-launcher\src\main\include/config.h:34:0,
[ERROR]                  from D:\src\imagej-launcher\src\main\c\config.c:32:
[ERROR] In file included from C:\Apps\jdk1.8.0_92-x64/include/jni.h:45:0,
[WARNING] D:\src\imagej-launcher\src\main\include/string-funcs.h:67:19: warning: inline function 'is_digit' declared but never defined
[ERROR] D:\src\imagej-launcher\src\main\c\file-funcs.c: In function 'find_jar':
[ERROR]                  from D:\src\imagej-launcher\src\main\c\ImageJ.c:68:
[ERROR] In file included from D:\src\imagej-launcher\src\main\include/file-funcs.h:34:0,
[ERROR] D:\src\imagej-launcher\src\main\c\platform.c: In function 'get_memory_size':
[ERROR] D:\src\imagej-launcher\src\main\c\splash.c: In function 'show_splash':
[WARNING] D:\src\imagej-launcher\src\main\c\file-funcs.c:379:7: warning: implicit declaration of function 'isdigit' [-Wimplicit-function-declaration]
[ERROR] In file included from D:\src\imagej-launcher\src\main\include/file-funcs.h:34:0,
[ERROR]  extern inline int is_digit(char c);
[ERROR]                    ^
[ERROR]                  from D:\src\imagej-launcher\src\main\c\java.c:33:
[ERROR]       !isdigit(name[prefix_length + 1]) ||

Though on closer look, it is not clear of this is really an actual error from a compiler or "label" added by Maven. The compilation actually completes. Binaries are created, but Maven build fails later with a message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (copy) on project imagej-launcher: An Ant BuildException has occured: Cannot perform operation from directory to file.
[ERROR] around Ant part ...<copy tofile="D:\src\imagej-launcher_fix-win10-sleep.git\target\ImageJ-win64.exe">... @ 4:128 in D:\src\imagej-launcher_fix-win10-sleep.git\target\antrun\build-main.xml

That is probably an issue the Ant task definition. I was running this with Maven 3.3.9.

I got what I needed, the binaries for the launcher :)

BTW: I was also able to build the binaries using CLion and the same mingw (v.4.9.3). Nice thing is that I can debug the launcher C code from CLion, though it is using CMake instead of Maven.

ctrueden commented 8 years ago

@jpsacha The NAR Maven plugin is not smart enough to distinguish between compiler errors and compiler warnings. So both such output gets prefixed with [ERROR]. Fixing this would probably be doable but nontrivial, if you want to try. (https://github.com/maven-nar/nar-maven-plugin)

The Maven build is failed only when the compiler returns a non-zero error code.

ctrueden commented 8 years ago

I got what I needed, the binaries for the launcher :)

That's the only reason you wanted to build? Why not extract them from the Maven repository instead then? http://maven.imagej.net/#nexus-search;gav~net.imagej~imagej-launcher~~~

Unless you needed to modify the code...?

jpsacha commented 8 years ago

I was hoping to fix some issues. There are a couple of different things I was going after. I also launcher for ImageJ 1, so I may be touching its parts that are not frequently used. One, as reported is issue #42, with the way launcher converts paths. For instance, * is not expanded correctly, slashes are mixed up, paths converted to DOS format. I was looking how this could be corrected. Though if that launcher is going away in favor native Java launcher, it may better to focus on new launcher.

Another thing was with high DPI displays (4K) that use scaling. Seems that the launcher worked better than ImageJ 1 launcher (Java 8). I was trying to figure out why. Turns out though that it only works till you try to create JavaFX thread, then UI suddenly shrinks. Not clear if this launcher or Java issue, though pure JavaFX applications work fine. Java 9 works better (with Swing), but many libraries do not yet correctly work with Java 9, like jai_imageio, FontAwsomeFX, etc (though I was able to patch a few, still need to post that code to GitHub/Bitbucket :).

ctrueden commented 8 years ago

@jpsacha Thanks for the info. I'm glad someone is exploring these things, since I personally have not had time.

If you want to play with the JavaFX launcher, you can generate it by cloning https://github.com/imagej/imagej and then running mvn -Pdist and looking in the target/jfx subtree. This is still highly experimental. But I'm really, really hoping we can discontinue the need for us to maintain that C code, since it is rife with (IMO) unmaintainable case logic.

See also imagej/imagej-launcher#33

jpsacha commented 8 years ago

I tried mvn -Pdist. Files get generated. I tried running target\jfx\native-nojre\ImageJ\imagej.exe. At some point I selected "Update...". That seems to ticke Symantec, it started complaining about SONAR.Downloader!gen2 infectiion and deleted several of the files including the generated imagej.exe. Did you come across this?

jpsacha commented 8 years ago

After reboot and doing the same things. There were no issues with Symantec.

jpsacha commented 8 years ago

The instructions provided by @stelfrich work on Windows, so I am closing this issue.

The JavaFX launcher is better discussed at imagej/imagej-launcher#33.