You mention using the DLL. How are you getting pointers to and calling those pointers? I wouldn't be surprised to see the stack is being corrupted due to different calling conventions. Also, why are you using the DLL? If you're writing a C++ app, why not just use the amalgamation?