java - How to get static final variables using JNA -
i using glew library glew32.dll (standard download glew website) , trying load variable glew_ok. variable defined in glew.h file (as uint of 0), assuming included in glew32.dll file. however, when use java jna code :
nativelibrary glew = nativelibrary.getinstance("glew.dll"); pointer p = glew.getglobalvariableaddress("glew_ok"); system.out.println(p.getint(0));
i given error of exception in thread "main" java.lang.unsatisfiedlinkerror: error looking 'glew_ok': specified procedure not found.
at com.sun.jna.nativelibrary.getglobalvariableaddress(nativelibrary.java:587) @ mcclean.opengl.glew.glewutils.init(glewutils.java:22)
the library loaded fine, appears static variable not found. why static variable not being loaded?
looking @ header file glew.h
, glew_ok
found such:
/* error codes */ #define glew_ok 0
this preprocessor definition. not "static final variable" conceive in java world. when c++ project compiled, preprocessor #define
s "copypasted" preprocessor code. means if (val == glew_ok)
literally changed if (val == 0)
.
since preprocessor replaces text, there no information names or origins of values originating defines in .dll
file.
you need manually find values. can downloading binaries glew , navigating include/gl/glew.h
file. after this, create class constants in java:
class glewconstants { public static final int glew_ok = 0; // ... }
Comments
Post a Comment