July 2005 Archives
I am now, unfortunately, an expert in how Microsoft Visual C++ links in and embeds library information. This is really a continuation of the issues I was having yesterday. Basically, it boils down to dealing with linker warnings such as:
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
and:
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
And while the first one is a warning, I've found that the resultant binary will crash. By using the depends.exe tool (which is also available separately from Visual Studio) to walk DLL dependencies, you can see both the debug (MSVC71D.DLL) and non-debug (MSVC71.DLL) libraries being linked in. This, not surprisingly, is a conflict, and hence causes a runtime crash.
These kinds of errors mean that you are linking together objects that have not all been compiled with the same runtime flag, /MD, /MDd, /MT, or/MTd. Sure you could just blindly add /NODEFAULTLIB:<whatever> to silence the warning, but that doesn't really solve the issue.
You see, the MSVC compiler embeds library information into every object file it creates. This means that a single file compiled with /MDd will mess up an entire /MD build. And this file could be in your code or any dependent static library. What is needed is tool that inspects objects and static libraries. The secret is using the dumpbin tool, provided with Visual Studio, to parse object files and static libraries. The /DIRECTIVES option dumps the linker flags embedded inside the object file. You should see /DEFAULTLIBRARY entries in the output, and this is how the linker decides which libraries to link against. dumpbin can also be used on static libraries (.lib files), but you will need the /ARCHIVEMEMBERS option to see which particular embedded object file the directives are associated with. From here, it's just a matter of some simple scripting to find out the one object file that was compiled incorrectly.
I'm working on a project that is a C++ library. Our main target platform is Windows using Microsoft Visual C++. As far as I know, there is no standard directory to put headers and libraries, and there is no naming convention for the library files themselves to help deal with runtime linking hell.
Without a standard directory, how should we do a binary release? Should we have the installer put them in C:\Program Files\<project>\? Or just C:\<project>\? Or do we just release a zip file, and let user unzip this wherever they want? Or both?
The runtime linking hell is an issue that resolves around these compiler flags: /ML, /MT, /MD, /MLd, /MTd, /MDd. These determine which C and C++ runtime library your code links against. And you must compile your code and all dependent libraries with the same flag or you are sure to get linker errors. So, ideally, we should distribute 6 variants of our library to make all possible users happy, and not require compiling our code. But again, where is it documented how I should do this? There is no standard naming convention.
For some good ideas and possible solutions, there are two good articles on GameDev.net: Static Library Tips and Making Your Libraries Release-Friendly. Granted there is still no standard, but it is quite useful information.
And while I'm at it, Unix and Mac OS X have their share of problems with libraries, too. OS X is the most advanced due to its frameworks, but it also inherits some bad habits from its Unix underpinnings. More on this in a later post, I think.
My 10,000th birthday (in binary... that's 32 for you non-nerds) was last week, and it's really been a music and gluttony filled weekend to ring in the new year. Thursday night, I saw Kid Koala at the Abbey Pub. He is a fantastic turntablist which you just have see to believe. This is no ordinary DJ... even those that scratch and mix. He just takes it to a whole new level. For a brief insight to what he's capable of, check out this Real video clip from the BBC of him remixing Henry Mancini's Moon River, live. I don't think even that video does him justice, but it's a start for newbies.
Saturday morning, we went to Cereality (hooray for stupid Flash intros!), a cereal bar and cafe. Thanks to Chicagoist, I've been looking forward to this place for months. And after reading Metromix's review, we decided to check it out. I loved it! Granted it was more like dessert than breakfast, with the sugar cereals and whole milk. They do have non-sugared cereals and skim milk, but what's the fun in that! And I can get my sugar cereal fix without buying a whole box. I'm looking forward to some Alphabits next time.
Saturday afternoon and evening was spent at Lollapalooza. Granted this was no Lollapalooza of old where you could see new and budding bands. I got to see the Pixies, again, Billy Idol, Primus, and Weezer. Okay, so we opted for the single day, and I didn't know half the bands that played on Saturday, so maybe there were some hip bands and I am just getting old to know who they are, but it was still a great time! I'm so glad they decided to play in Grant Park, rather than the usual places, such as Tinley Park or Alpine Valley. It was great to step out my front door a few feet and stumble to the show.
And to top off the weekend, we went to the ethereal Margie's Candies. Best. Butterscotch. Banana. Split. Ever. There's not much more to say, really. I'm still in a food coma, so check out Chicagoist for more info.
Why is it in this day and age, people cannot get online shopping checkout web pages done right? The site I was at this morning wanted me to enter a credit card number. Fair enough.... but, why oh why must the text field be "numbers only". Listen people, they added spaces and dashes to really long strings of numbers for a reason! Humans can read them easier! With spaces there, it's much easier to tell if I entered the number correctly. If your credit card processor requires only numbers, then strip out the goddamn spaces and dashes. How freakin' hard could that be?! I can't think of a single programming language where that wouldn't be more than 2 lines of code. Why must I suffer for your lazy ass programming skillz? Get a clue, or get another job! Oh, and fix your broken ass site.
And to add insult to injury, this site required I create an account with them before I checkout. Okay, it's the year 2005, and I've used your site once. What's the chance of me using your site again by the year 2015? Yup... you guessed. Close to nil! So why must I enter a password I'm guaranteed to forget if I ever do use your site again? And you probably keep my credit card information on file, supposedly to make my life easier that next time, but really you're just putting my personal information at risk. I don't trust you and your dumb programmers (see above) to keep my credit card information safe. You know what? I just want to buy my shit and go home.
Okay... I feel better now. I think I woke up on the wrong side of the bed this morning.
Last week I made some homemade mayonnaise, which, if you don't know, contains egg yolk, vinegar, lemon juice, and oil all mixed together. It's actually quite tiring to make as you've got to whisk very fast in order to get the whole thing to mix together. You're basically making two things that don't want to stay together, oil and water, stay together. Luckily with some elbow grease and the egg yolk to act as an emulsifier (it contains lecithin, the magic emulsifying ingredient), the mixture will stay together indefinitely, unlike, say, a vinaigrette dressing.
The outcome was really great mayo. The only down side is that it makes about a cup, and only lasts about a week. So I had to figure out ways to use up all that mayo.... I choose egg salad and crab cakes. Next time, I think I'll make some french onion dip or potato salad. Unfortunately, the store bought stuff lasts forever (how do they do that?), so I probably won't be making my own very often.
And for those attentive enough, yes, this is made from raw egg yolk. And yes, you could get salmonella, even though the chances are extremely small. You can avoid the issue all together with pasteurized eggs, and that's what I do. Pasteurized eggs are great... you can eat raw or undercooked eggs without the fear of getting sick. This means cookie dough, sunny side up eggs, ice cream, meringue, and yes, mayo. I've been able to readily find pasteurized eggs at both the Dominick's and Jewel near me. They come in these yellow containers that you have to watch out for, or you might not see them.
