简体   繁体   中英

Is it possible to build JNI .dll under Linux?

I'm using nar-maven-plugin 3.0.0 My pom resemble following:

<packaging>nar</packaging>

<build>
    <plugins>
        <plugin>
            <groupId>com.github.maven-nar</groupId>
            <artifactId>nar-maven-plugin</artifactId>
            <version>3.0.0</version>
            <extensions>true</extensions>
            <configuration>
                <libraries>
                    <library>
                        <type>jni</type>
                    </library>
                </libraries>
            </configuration>
        </plugin>
    </plugins>
</build>

And it actually works. Under my Linux it automatically finds gcc and use it to build everything and package it into nar. However this is .so file.

And my question is: Is it possible to configure it somehow to create under Linux nar with .dll next to nar with .so? And in general to produce JNI nars, to diffrent architectures?

If it possible please provide some configuration snippet, link or anything which can give me some clue.

  1. Copy the Windows JDK onto linux. Elsewise, you won't have needed headers and implibs. If you look, you will see that there are two JNI header files; one is per-platform . And, of course, you need an implib to link your DLL so that it can connect up to the JVM.
  2. Get https://fedoraproject.org/wiki/MinGW?rd=SIGs/MinGW , a cross-compiler environment.
  3. Teach the NAR plugin about (2). This might take some reading of the source of the NAR plugin.
  4. Mourn that you still need a Windows box to test the results .

So are you sure you want to do this? I very much doubt that you will find that this is a common, supported, practice, because most of us want to test the things that we build. Since you need actual Windows to test, you might as well build there.

Yes, but it requires a cross compiler for each platform you wish to traget. Your Jar's build process will also need to be cross-compiler aware.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM