javacpp icon indicating copy to clipboard operation
javacpp copied to clipboard

Windows Development - Use GCC compiler

Open benshiffman opened this issue 1 year ago • 1 comments

I've had great success on Linux with javacpp, but my particular library doesn't play nice with Windows' CL compiler. I'm attempting to use Cygwin with gcc to run javacpp on my generated class file to create the JNI mappings, but it's still looking for cl.exe. Is there a way to specify a compiler for javacpp to use?

Update: I discovered the -Dplatform.compiler=gcc flag, but running into another issue: it seems that none of the include paths are working because of the path format of the Cygwin/mintty terminal I'm using. Even files within my project folder are not found. Is there perhaps another flag to specify working directory path?

benshiffman avatar Aug 10 '22 21:08 benshiffman

There are properties for MinGW: https://github.com/bytedeco/javacpp/tree/master/src/main/resources/org/bytedeco/javacpp/properties On the command line, we can use those with something like java -jar javacpp.jar -properties windows-x86_64-mingw, but if you need to modify those properties, we can specify a file instead, like java -jar javacpp.jar -propertyfile /path/to/your/windows-x86_64.properties. Does that answer your question?

saudet avatar Aug 11 '22 04:08 saudet

Hi @saudet, so sorry it's taken so long to get back. I've installed mingw64 and tried many configurations using the flag you mentioned, but I'm still coming up with the same error shown in the attached screenshot. errormsg

It seems there's a dependency on mingw64's dlfcn library which I haven't been able to resolve by installing any of the packages listed here.

Is there something I'm overlooking?

benshiffman avatar Aug 18 '22 18:08 benshiffman

It looks like you're trying to use compilers for Cygwin, that won't work with JavaCPP, we need to use compilers for MinGW, for example, the ones here: https://github.com/bytedeco/javacpp-presets/wiki/Build-Environments#windows-x86-and-x86_64

saudet avatar Aug 19 '22 00:08 saudet

After configuring MSYS and running javacpp through mingw64 (both via the mingw64 shell and the Native Tools Command Prompt) the above errors have disappeared, but I'm getting a bunch of undefined references to most of my library's functions. I wish I could provide a screenshot but I am working with controlled information here. I should mention that I'm not working with javacpp-presets; I'm following Mapping Recipes.

benshiffman avatar Aug 19 '22 18:08 benshiffman

If your library requires Cygwin to run on Windows, that's going to be hard, if not impossible, to get working with JNI. You might need to start looking at other options like sockets and what not.

saudet avatar Aug 19 '22 22:08 saudet

I gave CL.exe another crack and finally found the root of the errors. There was a missing 3rd party library which cl didn't make very apparent. Compiled with ease!

Thanks again for being so active here, this is really an amazing piece of software!

benshiffman avatar Aug 22 '22 19:08 benshiffman