LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

receiving fatal runtime faults from c++ dll

I am receiving fatal runtime error 'general protection fault' when calling functions in a dll generated by MS C++.
 
function call coded as :
 
extern "C" __declspec (dllexport) long __stdcall IOGetMessageResponse(char *TxMessage, char *RxPattern,
           char *RxMessage, long lngTimeOut,
           long lPortNumber, int& ipRcvCount,
           double *dElapsedTime);
 
After researching 'general protection fault', CVI says it expects dll(s) to be built with __stdcall instead of __cdecl so I have switched it to __stdcall, but it still crashes with same error.  Can you
help?   
Carl Nothnagle
309-494-4156
0 Kudos
Message 1 of 2
(2,917 Views)
Hi Carl,
 
I would be glad to help you with this question. I would recommend that you take take the following steps in order to use your C++ dll in CVI:
 
1) Make sure that you can call the dll you created from C++
 
2) Generate your C++ dll with the format __declspec(dllexport) int __stdcall myfunction(int a, int b)
 
3) After creating the .c file, .h file, and compiling your dll, copy the dll into the current CVI project directory or c:\windows\system32
 
4) In CVI, create a new project and include the .h file for your dll. When editing this .h file, click on Options >> Generate DLL Import Library in order to create a *.lib file for statically linking your dll into your CVI proect. Click on Edit >> Add Files to Project in order to add the created library file.
 
5) You should now be able to run the dll that you created without any errors
 
If you plan on dynamically linking your dll, you will not not have to use an import library. Dynamically linking is a bit more dificult, and requires you to use the LoadLibrary function. Please let me know if you have any additional questions and I would be glad to help you further. If your dll still does not appear to work after following the above steps, I would recommend that you attach the *.dll file to your next post so that I can try it out on my end and we can move forward from there.
 
Regards,
 
Casey Weltzin
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(2,897 Views)