My first run-in with Managed Code
I've heard complaints about dealing with managed code and headaches dealing with mixing managed and unmanaged code but for the most part these problems have been just bits of conversation to me. Until now. See, the last version of Visual Studio that I used for really intense work was VC6. I still feel that the product's been riding down the crapwave ever since. In the interim most of my work has been in Linux or cross-platform script stuff. I've got a little project that I'm currently trying to get building on Visual Studio 2003. It uses SDL and Lua. Basically I want to build a little test harness, but more on that later. I already had the project building in Linux using just the SDL libraries then I created a project in VS2003 to build the same source. I followed the description from this thread on The SDL project built and all was well. When I tried to add Lua using a prebuilt binary I ran in to issues with symbols redefined in libc.lib or (if I ignored that library) _errno being undefined. This seems to be caused by the fact that the Windows version of the Lua library was built to be single-threaded but my SDL app was built with the multithreading flags. I fought with it for a while but in the end I just grabbed the Lua source and added it as another project in my workspace (sorry, "solution"). As it turns out the project file included with the source (see the Lua Binaries download page) has a project file that built just fine for me. Then I had to remember to make sure my SDL app was including the headers from this new code, linking with the library file and loading the created DLL. So far I did some of this manually (copying the DLL to the same folder as the EXE) but in time I'll refine the project to do it as part of the build. There were other settings I had to mess with to get things to build and some of them were strange and inexplicable. I wish I knew which changes fixed things so I could record that here. Even after it built though, I got one last bizarre error at run time before main() executed. I'd get the following error: An unhandled exception of type 'System.TypeLoadException' occurred in Unknown Module. Additional information: Could not load type lua_State from assembly hilbert, Version=, Culture=neutral, PublicKeyToken=null. Luckily someone's had this problem before and there was an answer in this Lua Users mailing list thread. Basically it boils down to having an empty declaration of lua_State like so in your files struct lua_State {}; The first time I tried placing this in my main cpp file I got errors about failing to cast from SDLmain::lua_State to lua_State and vice versa. It seems that something wasn't rebuilding though because I just tried to duplicate that problem and it won't come back - I guess that's just a reminder that when things should work and act funny you should always do a clean build. So in the end now all I needed was that line above the start of main() and my little test app now runs and executes a one-line Lua script. As for the purpose of the harness and some source code, I hope to be able to come up with that later on in the week. I have to say though that working with Visual Studio 2003 has some nice bits but overall it makes me anxious to get back to my Linux box.
Your rating: None

That link you referenced says it\'s a problem when mixing unmanaged code with a managed .NET project. So why are you using a managed .NET project?!? Problem should go away if you\'re using pure unmanaged stuff from start to finish, no?

I expect so but as far as I understand it managed code is the norm now.