ymgamal wrote:Add logging to the C code. The logger writes to a file at various points, based on the calls you make to the logger code. You then follow the process flow via the output in the file.
I am working on a project which involves making a C API accessible to java programs. I have most of the capabilities working. Unfortunately, the two callback functions needed from the API are not fully working. I have the callback setup working properly (I am still working out some GlobalRef stuff and trying to understand AttachCurrentThread) in the situation that I do the callback from the main Java thread. I am having two main issues:
1) The callback is supposed to happen when a particular report comes in over USB from a microcontroller. Currently, the program is setup to call an intermediate C function which does some things then executes a CallVoidMethod(.....) into the java callback function. Currently, I don't think I even get into the intermediate C function, as I set a global in the function (and when I read it out in java, it never gets changed). I am more of a C guy, so the whole multi-thread world is pretty new to me. I feel like there was an important step here that I am missing.
2) When I make the C API dll with the wrapper functions, the only functions I can access after that are the java JNI functions. Why is that? How can I fix that? I am using cygwin/mingw32-make and a make file, but here is the gcc command executed:What do you mean by "access"?
gcc -mwin32 - shared -o API.dll *.o -lhid -lkernel32 -luser32 -lsetupapi -lwinmm -Wl,--kill-at
I am already using print statements to see where I am at. None in the C code get called, unless I explicitly call a JNI function to it.I am really confused by this. How else would the C code be invoked? This is about JNI so it is about a Java application invoking native code. Of course you need to do an explicit JNI controlled call (IE. call a method in a Java class which is marked as native) to get the native code to do anything.
ymgamal wrote:If you really are a "c guy", you shouldn't be having to ask this. Don't make it any more difficult than it needs to be. You have "a DLL", no matter where it comes from or what it is used for, that needs to interface with "another DLL". How do you effectively do that? Whatever the case, Java does not exist in that problem description so don't look for solutions relating to Java.
I will look into keeping the java dll seperate from the original dll, so if you have any good links to start with, that would be greatly appreciated.