Skip to content
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

How to build from source? #4

Open
ErichDonGubler opened this issue Apr 3, 2018 · 7 comments
Open

How to build from source? #4

ErichDonGubler opened this issue Apr 3, 2018 · 7 comments

Comments

@ErichDonGubler
Copy link

It's unclear how to build from source at the moment. Attempting to build from a Windows 10 box for the stable MSVC target with no attempt at special configuration yields:

~/…/experiments/rjni master$ cargo build --example instance
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling libc v0.2.40
   Compiling rjni v0.0.1 (file:///…/experiments/rjni)
error: linking with `link.exe` failed: exit code: 1181
  |
  = note: // snip, horribly long linker invocation
  = note: LINK : fatal error LNK1181: cannot open input file 'jvm.lib'

I understand that this project is a work-in-progress, and this may not be an immediate priority for you. However, adding documentation like this will enable people to experiment and contribute, if it's something you think might help this project along. :)

@benanders
Copy link
Owner

Thanks for taking an interest. You're right, this project isn't a huge priority for me. I unfortunately don't have a Windows box to experiment on at the moment.

For some reason, macOS requires a legacy version of Java (Java 6) in order for the JNI to work. Maybe you could try downloading the equivalent for Windows? Other than that, I'm out of ideas really. Sorry.

@joshbooks
Copy link

joshbooks commented Apr 5, 2018

macOS requires a legacy version of Java (Java 6) in order for the JNI to work.

pretty sure that's not right, I recently (last job) built a java application for mac with jni components using java 8 (built the app using javafx though, which does a bunch of weird stuff)

@benanders
Copy link
Owner

Yeah all the API calls that RJNI uses are documented in the Java 8 JNI documentation. So I'm sure there's a way to get the project working with Java 8, but for some reason every time I try and use RJNI macOS asks me to download a legacy Java version. Probably something to do with how I'm building the .class files and instantiating the JVM.

@joshbooks
Copy link

definitely to do with how you're instantiating the jvm, if you double click a .class file or some equivalent mac pops up that stupid message

@joshbooks
Copy link

joshbooks commented Apr 5, 2018

I think the first way I got it to work outside Intellij was to build an app with platypus since apple doesn't like for any java thing to be the primary target of a .app

@joshbooks
Copy link

joshbooks commented Apr 5, 2018

this stack overflow post gets it to build (if you make sure you have the right target for your machine) and adding the location of jvm.dll to PATH gets it to run (usually jre/bin/server)

@joshbooks
Copy link

so I inserted this into my cargo config (%USERPROFILE%/.cargo/config)

[target.x86_64-pc-windows-msvc.jvm]
rustc-link-lib = ["jvm"]
rustc-link-search = ["C:/Program Files/Java/jdk1.8.0_161/lib"]
root = "C:/Program Files/Java/jdk1.8.0_161/lib"

changed the Cargo.toml to this

[package]
name = "rjni"
version = "0.0.1"
authors = ["Ben Anderson <[email protected]>"]
links = "jvm"
build = "src/build.rs"

[dependencies]
libc = "*"

added C:\Program Files\Java\jre1.8.0_161\bin\server to my PATH env variable, and now it runs on my windows machine, you'll probably need to change some of those paths

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants