The Call of CthLua...

A place for Ogre users to discuss non-Ogre subjects with friends from the community.
Post Reply
User avatar
stoneCold
OGRE Expert User
OGRE Expert User
Posts: 867
Joined: Fri Oct 01, 2004 9:13 pm
Location: Carinthia, Austria
x 1

The Call of CthLua...

Post by stoneCold »

... drove me mad this night (nearly).

Ok, now sersiously...
Today I spent a reasonable time debugging some strange behaviour of an application that I'm working on.
It's got several dependencies and amongst them .... Lua .... (or shall I say Cthlua :twisted:)
For some weird reason, the application would run fine on the pc that it was build on, as well as on every pc that had Visual Studio installed.
Without Visual Studio beeing installed, the application would just crash with the well known "The Application failed to initialize properly ( 0xc0150002 )" message.
After at least one hour and 3 failed attempts to debug/solve the problem I stumbled across the so called "Windows Event Logger", while doing the thousandth google search containing "0xc0150002" + some other keywords.
Up to this moment, I would never have thought that the Event Logger would tell something useful to guys, who are debugging their own applications.
But I nonetheless opened the Logger and what I found there was something like that:

Generate Activation Context failed for c:\whatever\path\myDll.dll. Reference error message: The referenced assembly is not installed on your system.

Since the appropriate VC Runtime was installed on the system(s) I quite quickly came to the conclusion that one of the dependencies of myDll had to cause the trouble.
So I started to rule them out one by one, until I arrived at Lua, once I removed the linking to Lua, everything became peanut butter-jelly bread again (meaning: "it started working again").
Further investigation on the Lua binaries (that I've built myself and therefore shouldn't be linked to a different VC runtime version), revealed that Cthlua, the worst of all the great old ones, used the same output names for both it's Release and Debug builds, namely lua5.1.lib.
So in essence I linked the Release build of my application to the Debug build of a Lua library and (of course) the VC runtime was not amused about this fact.

So what do we learn from this little horror story of mine...
  • Do know your Windows Event Logger, it sometimes has got useful information for the desperate.
  • Microsoft's VC Runtime Mumbo-Jumbo can really harm your application (silently) if you aren't aware.
  • And most importantly, be aware of the great Cthlua, with it's tentacle butt and it's inconsistent binary naming :D
I simply had to write this down somewhere, otherwhise the short glimpse that I've got of great Cthlua would have driven me mad.
Maybe with VS2010 things will become better again, at least I hope so.

/start VC Runtime flaming here :D

Cheers
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: The Call of CthLua...

Post by nullsquared »

Ouch. I created my own Lua project so I didn't encounter this issue :mrgreen: You might also want to compile Lua as C++ instead of C in case you get into some exception trouble with Lua, which gets disguised as a deep internal crash that you can't really trace to anything useful if Lua is compiled as C.
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: The Call of CthLua...

Post by Klaim »

Same as nullsquared, when using Lua I always choose one of the two options:
- create a custom C++ project in visual studio, be it static library or dll;
- add directly the lua code in my project;

I never got any problem that way.
Post Reply