Try putting the dll_open as the first line of your main function. This solved a similar problem for me.