Wednesday, September 7, 2011

Handling - Runtime Error R6034 Application attempted to load the C runtime lib incorrectly

Handling - Runtime Error R6034, An application has made an attempt to load the C runtime lib incorrectly

  1. This could mean that you have linked against both the debug and release versions of the C runtime library (msvcrt.lib)
  2. This blog post is very useful: http://www.insidercoding.com/post/2008/07/21/Debugging-issues-with-MSVCR90DLL.aspx


Another possible cause is linking a debug version of a static library when building a release version of your executable. The executable will run on a development machine because the development machine has both the debug and release versions of the DLL installed (



Adding MSVCPRTD.LIB to the list of ignore libraries prevented that library being automatically linked to the project. This caused the linker to show which static library was trying to import the debug dll.

NOTE: Need to create a test project.... an exe which imports a static lib. That static lib should be built in debug config and should use a debug function....... when the exe is built in release mode it will not run on a customer machine (one that doesn't have VS installed) and will bomb out.... show error message there.... But how can you figure out what DLL it is trying to load (maybe it's in the error message).... a good way is to use depends.exe..... check out the profiling tool in it..... show clearly that both the debug and release versions of depends are being searched for... Depends also shows what function that exe is trying to call in the debug version of the DLL..... But how can you figure out which static library that you're linking against is causing this?

So now you know the DLL and the function in the dll you can continue debugging.... the next step is to add the MSVCPRTD.LIB to the ignore specific libraries since you know you don't want to include this..... explain what the MSVCPRTD.LIB is.... also discuss other potential libraries which could cause this error.... finally try building the exe with this setting.... if the correct library is ignored then the static library will not link correctly and the link will fail.... the linker error message will display the function as a missing external symbol and also show which static library the function is being called from.... in my case the static lib I was linking against was built in debug mode but accidentally copied into the Release folder.... I simply dropped in my release version of the static lib, rebuilt and everything worked....


MSVCPRTD.LIB; msvcrtd.lib

Wednesday, August 10, 2011

Calling Const Functions

I learned today that if you have a const object then the compiler will only allow you to call const methods on that object (i.e. methods which are guaranteed not to changed the state of that object). So how do you tell the compiler that a method won't change the object? Put const at the end of the method declaration:
void MyClass::myConstFunction() const
{
   ....
}

I hit this issue when I was writing a copy constructor with the following signature:
man(const man& m)

I tried calling m.getName() to retrieve the man's name but because I didn't declare getName() as a const method I got the following error (I was using Visual Studio 2008):

error C2662: 'man::getName' : cannot convert 'this' pointer from 'const man' to 'man &'

I realised during my debugging that I didn't need to call a getter because the copy constructor could access the private members of the other man object. Here's the great article that helped me.

Friday, June 10, 2011

Setting Network Device Priorities on Windows 7

I have a laptop at work and dock it when I'm at my desk. So I want to use my wired connection at my desk and wireless otherwise. However when I docked my machine it still used the wireless even though the wired connection was faster. I found these simple few steps to fix this here:

  1. Go to the "Network And Sharing Center" window click "Change Adapter Settings"
  2. On the "Network Connections" window, press the ALT key on your keyboard to being up the menu bar
  3. Click the "Advanced" menu and then "Advanced Settings"
  4. In the "Advanced Settings" window you will see the "Adapters and Bindings" tab and under "Connections" you will see the order they are in, you can use the arrows to the side to move the connection priority up and down.

Friday, February 4, 2011

InstallShield Automation Interface on 64-bit System

If you use a script to automate your build process using the InstallShield 2011 Automation Interface on a 64-bit OS you must call the script using a 32-bit process. Otherwise you may get this error: "Automation server can't create object" (error code: 800A01AD). Launching the script from a 64-bit process like C:\Windows\System32\cmd.exe you'll get the following error:

To get around this use the 32-bit version of command prompt which is here: C:\Windows\SysWOW64\cmd.exe. For more detail see InstallShield's webpage about this issue.