This content has been marked as final. Show 3 replies
I get this error only when building a native library with /MD on Win64.Don't you mean when executing on Win64?
I was never able to get JNI working with /MD even on 32-bit systems, and that was at a time when I had considerable expertise in /MD and building DLLs generally.
If you design your interface to your other C code carefully you don't need to use /MD for the JNI DLL.
This appears to be a general problem with building a 32 bit app with /MD then executing in a 64 bit windows environment. At run time load library finds a 64 bit version of the c runtime hence the 32 bit library fails to load. Fortunately we are moving to 64 bit builds of our app so I am now generating 64 bit builds myself. I have no problems with /MD when all is 64 bit. By the way, building with /MD is requirement imposed by 3rd party libraries I depend upon so removing it is not an option.
MichaelT wrote:An alternative still exists. Do not use JNI. Instead
By the way, building with /MD is requirement imposed by 3rd party libraries I depend upon so removing it is not an option.
1. Wrap the target native code in an executable.
2. Add a communication api.
3. Test and debug as the executable.
4. Run the executable via Runtime.exec/ProcessBuilder
5. Execute the functionality via the communication api.
No JNI in the above. Also no possibility that the native code can crash your VM. Even if the exe crashes you can add restart code to deal with it.