LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Solution: Visual C++ Runtime Error: R6030 -CRT not initialized

I'm starting this thread as information for others. I had an issue in CVI2013 that I didn't have with CVI8.1:

 

I have a project that uses NI libraries (vision and imaqdx amongst others) and two 32bit libraries (one is for a USB motion controller and the other for an ethernet motion controller). In CVI8.1, this compiles and runs fine, but in CVI2013, it compiles but when I execute it, I get a Visual C++ Runtime Error: R6030 -CRT not initialized. I uninstalled and re-installed all of the VC++ redistributables from 2005 to 2013 with no luck. I also removed my AVG antivirus and replaced it with MSE with no luck. UAC is off on this machine.

 

1) I have a small test application with just the ethernet library (and some NI libraries but NOT the vision) and it runs fine in CVI2013

2) If I use just the USB library, my project (which also uses the vision library) works fine

2) If I use just the ethernet library, my project (which also uses the vision library) has the VC++ error

 

After a lot of searching on the Windows side of things, I realized that I might have the same problem as this thread:

http://forums.ni.com/t5/LabWindows-CVI/CVI-EXE-producing-R6030-CRT-not-initialize-d/m-p/2304730/high...

 

The underlying reason for the crash might be here:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/99029f46-bf9c-48f6-9351-1f5c7f61d946/choosing...
https://msdn.microsoft.com/en-us/library/abx4dbyh.aspx

 

Solution:

Since I could not rewrite the DLL (supplied by 3rd party), I decided to try a few things. I was initialliy linking the DLL statically by adding the .LIB file to my project so I switched to using dynamic linking with the Windows API (LoadLibrary()). Writting the necessary GetProcAddress() calls for all of the functions is the worst part in going this route, but some headers include those...

 

This resolved the crash issue in CVI2013 and works in CVI8.1 as well.

Good luck!

Message 1 of 2
(29,170 Views)

I'm having an almost identical problem with CVI 2015 (15.0.0).
I added a DLL (test1.dll) to a program thats been working for years and now it throws a C++ Runtime Error: "Runtime Error! ... R6030 -CRT not initialized" error every time upon execution, debug and release mode.

I tried including the DLL as the only DLL in a test project and it works fine.
After trying to track this down for a day, I finally noticed that the error occured in the DllMain function of a different DLL (CAN.dll) during the DLL_PROCESS_ATTACH.
CAN.dll called InitCVIRTE(hinstDLL, 0, 0) without a problem. The very next line I had 
panelHandle = LoadPanelEx(0, "zzz.uir", PANEL, hinstDLL);
The C++ Runtime Error happened when executing this line.
This method of loading a panelHandle into global memory had worked fine for years, but for some reason with the addition of the test1.dll (the 11th dll in the project) it no longer works.
I went back to a separate test project and added only test1.dll and CAN.dll. Sure enough, those 2 DLL's could not play nicely together for some reason.
The solution was to rewrite the CAN.dll to not call LoadPanelEx from within DllMain. Instead I made a separate initDLL function that must be called first before using any of the others.
Even though it works, I don't really like the solution. If anyone knows why this is a problem or other potential fixes, please respond. I have yet to try the GetProcAddress() solution above since it would be a significant effort in my situation.

0 Kudos
Message 2 of 2
(20,970 Views)