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

doesn't work on windows #9

Closed
tfriedel opened this issue Aug 21, 2012 · 3 comments
Closed

doesn't work on windows #9

tfriedel opened this issue Aug 21, 2012 · 3 comments
Labels

Comments

@tfriedel
Copy link

was trying to compile it with mingw and vc 2008, but even after adding the correct includes from the jdk (subdir "win32"), I get this error:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG "-Ic:\Program Files (x86)\Java\jdk1.7.0_05\include" "-Ic:\Program Files (x86)\Java\jdk1.7.0_05\include\win32" -IC:\Python27\include -IC:\Python27\PC /Tcjnius\jnius.c /Fobuild\temp.win32-2.7\Release\jnius\jnius.obj
jnius.c
jnius\jnius.c(961) : error C2373: 'JNI_CreateJavaVM': Neudefinition; unterschiedliche Modifizierer
c:\Program Files (x86)\Java\jdk1.7.0_05\include\jni.h(1938): Siehe Deklaration von 'JNI_CreateJavaVM'

@Nesquik
Copy link

Nesquik commented Jan 11, 2013

I've hit this bug too. What I've done is modify this line in jnius_jvm_desktop.pxi as said on IRC:

cdef extern jint  __stdcall JNI_CreateJavaVM(JavaVM **pvm, void **penv, void *args)

After that it looks like the linker has some issues with it:

build\temp.win32-2.7\Release\jnius\jnius.o:jnius.c:(.text+0x11d1): undefined reference to `__imp__JNI_CreateJavaVM@12'

These are the additions I've made to the setup.py in order to try and comply with the needed reference for that function:

elif platform == 'win32':
    cpu = 'i386' if sys.maxint == 2147483647 else 'amd64'
    jdk_home = environ.get('JDK_HOME')
    jre_home = environ.get('JRE_HOME')
    cpu = 'i386' if sys.maxint == 2147483647 else 'amd64'
    include_dirs = [ join(jdk_home, 'include'), join(jdk_home, 'include', 'win32')]
    library_dirs = [ join(jre_home, 'bin', 'server') ]
    extra_link_args = ['-Wl,-rpath', library_dirs[0]]
    libraries = ['jvm']

but no luck.
Any suggestions on how to fix that is appreciated.

@skern
Copy link

skern commented Mar 3, 2013

This configuration worked for me:

elif platform == 'win32':
    cpu = 'i386' if sys.maxint == 2147483647 else 'amd64'
    jdk_home = environ.get('JDK_HOME')
    jre_home = environ.get('JRE_HOME')
    cpu = 'i386' if sys.maxint == 2147483647 else 'amd64'
    include_dirs = [ join(jdk_home, 'include'), join(jdk_home, 'include', 'win32')]
    library_dirs = [ join(jdk_home, 'lib'), join(jre_home, 'bin', 'server') ]
    extra_link_args = ['-Wl,-rpath', library_dirs[0]]
    libraries = ['jvm'] 

After building, there is a file "jnius.pyd" which is the DLL, so rename it to "jnius.dll".

@kevlened
Copy link
Contributor

I used this guidance in a pull request to get Windows working. Thanks!

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

No branches or pull requests

5 participants