MinGW to the rescue!

Ugh, sometimes doing consulting work is like riding a rollercoaster.

Lately I have been working on a really interesting project that involves integrating a couple of libraries into a very large and powerful application with accompanying SDK, along with whatever code that I write to make it all extra cool. Only problem is, the libraries are open-source libs (LGPL, thank you!!), primarily developed to build on UNIX systems, and the application I am integrating into takes Win32 DLLs. That by itself is enough to make my hair stand on end… but, off we go!

I started out wanting to use Visual Studio 2003, figuring that the visual debugger was going to really come in handy. My crib notes went something like this:

Step 1: Build (library 1) …

After about 2 hours of thrashing around on that attempt, I updated my notes:

Step 0: Close Visual Studio and start a Cygwin command-prompt.

Step 1: Build (library 1) …

Oh well. At least I’m proficient with GDB.

Cygwin seemed to be a lifesaver here; I got my libraries building pretty quickly, and then it wasn’t much harder to integrate into this application’s SDK and get a DLL ready for testing. “Cool… here goes nothing…”

Problem 1: Can’t find cygwin1.dll…

OK, here’s where it’s at, you baby.

Problem 2: The application goes, “Plugin loaded successfully! Yay!” (FALLS OVER DEAD)

Now what?!

This is where I nearly gave up. GDB very helpfully pointed out that there was a segmentation fault (thanks!), but other than that, no clue.

But, in one last-ditch attempt to get this to work, I decided to try out MinGW. I was leery about having two different versions of UNIX on my Win32 laptop (“Will they fight?”), but what can you do? The MinGW installation instructions were pretty confusing to me - “There’s this one thing called ‘MSYS,’ and another thing called ‘MinGW,’ but really there’s like ten things and you get to pick what you want…” Ugh, I just want to get this working! Where’s the “MinGW for Dummies” section? So I just found something that looked like an installation package and gave it a whack. And it seems like my guesses were good - it all actually seemed to work!

It wasn’t too hard to get my plugin compiling to a DLL under MinGW, and then when I installed that into the application, everything seemed to work great. So finally I got that integration pain out of the way, and I can concentrate on the fun stuff…

So, to be completely honest, the application’s SDK didn’t really say that it supported Cygwin; it said it supported MinGW, and I thought that Cygwin would be just fine. “MinGW forked off of Cygwin, right? Surely it’ll be okay.” But, for whatever reasons, Cygwin just doesn’t play nice with that app.

Although MinGW saved my bacon here, I did come across one very humorous bit of MinGW brain-damage. When you symlink something in Cygwin, it’s pretty clever about it, and actually creates a .lnk file that Windows can comprehend. MinGW? It just copies whatever you’re symlinking, to wherever the link is supposed to be. Is it a directory? “No problem! I’ll just copy the whole thing…”

That made me chuckle.

Leave a Reply