Friday, December 22, 2006

Linking 101

For many software developers, this post will be linking-101. Yet, recently I was looking into an issue on Windows (yes, I know), where an application developed using Visual Studio 2005, was linking against a libary developer with Visual C 6. I needed to understand a little more on how linking works in Windows. Many of these bullet points are known secrets. But if you lived too long in the Unix world, the Windows secrets will be a mystery and vice versa. So here's a short summary:

Windows
  • .dll is the extension for a Windows dynamic library. DLL Hell exists and even has a Wikipedia entry.
  • .lib is the extension for both a DLL wrapper, as it is used for static libraries. A DLL wrapper or "import" LIB file, which is used to link against. For each function the DLL exports, the LIB file contains a stub which will load and call into the DLL. You only need these .lib files when linking, but not when deploying.
    • If on Windows a DLL is missing, you will get hit during run time, as it can not find the DLL module to load. On Unix, the application will not start up. This has pro's an cons. Pro: if you do not want to use a particular feature of the application, which requires an expensive 3rd party library, you can still run the application. The con: if your application was doing a lot of work and then aborts, you will slap the machine a couple of times.
  • Convention: Files ending with z.lib or zd.lib are the static libraries. (d for debug)
  • C Run Time (CRT) libraries are development environment dependent. If your program links against both, you have to be very very careful. Since memory management are (slightly) different between CRTs, linking against malloc()/free() from different CRTs can corrupt your heap. The bug will unfortunately show up in weird and unrelated ways. The take away is avoid linking against two different CRTs. But if you have to, make sure you keep your program modules separate. For reference:
    • msvcrt.dll is used by VC6.0
    • msvcr70.dll for VS .NET
    • msvcr71.dll for VS .NET 2003
    • msvcr80.dll for VS 2005
    • with "d" added to the name for debug CRTs
Unix
  • Static libraries (archives) are created and updated by the ar (archive) utility. Convention dictates that static libraries have a ".a" extension on their filename.
  • Dynamically linked libraries are created by the link editor, ld. The conventional file extension for a dynamic library is ".so" (shared object).
  • You tell the compiler to link with, libpthread.so, by giving the option -lthread.
  • The compiler finds libraries as specificied by LD_LIBRARY_PATH or using the compiler option -Lpathname.
  • nm utility to the rescue when you run into Undefined Symbols
  • The order of statically linked libraries on the compiler command line is significant: (i..e they should be listed after your own code). Although I believe gcc can be instructed to make a few passes through the static library arguments to make sure undefined symbols, defined in previously stated static libraries are picked up.
  • Knowing which library files to link against is sometimes a mystery. Take a look at the #includes and guess the library name. Often the man pages might mention something as well.
An excellent book on gotchas, weird bugs and behaviors is Expert C programming - Deep C secrets, by Peter Van Der Linden. It is not a C programming text book. It is a collection of C programming experiences (aka the stuff for which experienced programmers get paid the big bucks). I happen to work on a few projects ((USB/CDRW) with Peter, when he was leading the I/O team in the Sun workstation group. He is a very interesting guy, who wrote many programming books from C to Java and Linux. Here's an interview with Peter from ITConversations.

Technorati:

Monday, December 11, 2006

E n g l i s h !

Living in the Bay Area, you hear a lot of different dialects, accents and levels of the English language. I am not a native English speaker myself, so I won't proclaim to be proficient in it. There are however two expressions which annoy me tremendously. More and more native English speakers are starting to use them. Argh!
  1. Long time no see - when meeting somebody after a long while. Wikipedia expands: "Long time no see" is a common Chinglish term, meaning "I haven't seen you for a long time"
  2. My bad - when making a mistake. Mea culpa.

Wednesday, December 06, 2006

It's about the data, stupid!

If you read my blog over the year (Software as a service, it's about the data platform) (Saas infrastructure, an update), you understand my view on who will hold the best cards on the internet in the future.

Today, I learned on TechCrunch about a interesting new company, who puts data central to their business: Swivel. "Swivel is a place where curious people explore data — all kinds of data.", according to their website. Ha! Right up my alley. It is like Chart of the Day, but then for all kinds of data. Here's an interesting one comparing Wine and Crime data sets (based upon 25 data points, imported from www.ers.usda.gov and bjsdata.ojp.usdoj.gov). How related are these items to one another? 77%, according to Swivel.

1054868

Swivel allows you to customize the graph and generates the html to embed into your blog. This might an interesting company to keep track of. .. mmh.. let's chart out Swivel page visits against the amount of newborns.

Technorati:

Netbeans C/C++ official release

I've been working with Netbeans and CND, the C/C++ pack for several months (see also Netbeans CND: revamped import wizard). Today is the official release of both Visual Web Pack (aka Creator) and the C/C++ Pack. Hurray!

Technorati:

The Biota bottle

Here's one of the coolest product I've seen in a while. My wife was sipping from a bottle of spring water: Biota, Colorado pure spring water. I had never heard of the brand. The name apparently stands for "Blame It On The Altitude(r)".

The water tasted great. It feels like a regular plastic bottle. And the logo is like any other logo for spring water: blue and with a snow covered mountain.


Until you read the label: the bottle is compostable!! COMPOSTABLE! How great is that?
BIOTA uses nature-based packaging from NatureWorks ™ PLA. NatureWorks ™ PLA is the first commercially viable packaging material derived entirely from an annually renewable resource - corn. BIOTA is the first beverage company in the world to exclusively use NatureWorks ™ PLA to bottle its products. BIOTA water bottles are completely compostable. They are approved and certified as commercially compostable by the Biodegradable Products Institute (BPI). Initial testing has demonstrated that a BIOTA water bottle will degrade within 75 to 80 days in a commercial composting situation. A traditional plastic bottle will never biodegrade.
The information site has more details on the conditions under which composting works well:

How does the BIOTA bottle composting process work?
BIOTA bottles need high heat, micro-organisms and high moisture levels to break down. A BIOTA PLA bottle will not degrade as rapidly in a home compost pile. When exposed to the necessary conditions, BIOTA bottles will break down into water, carbon dioxide and organic material.

How long does it take for a BIOTA bottle to disappear?
Given the right composting conditions including high heat, humidity and micro-organisms, a BIOTA bottle will disappear in 75 to 80 days...basically 12 weeks.

Technorati:

Sunday, December 03, 2006

Boom!

I am a big fan of Presentation Zen. The blog has a tremendous amount of info and tips on becoming a better public speaker. Steve Jobs is often used as an example. Here he is in real good form:

Tuesday, November 28, 2006

Pushing buttons

The Wall Street Journal featured an article "Must Consumer Electronics Be So Complicated?". The question can be posed for any human - machine interface. Most often is the interface overly complicated. I am sure you have your own list of favorite device interfaces or horror stories of complicated user interface. The iPod interface for sure rocks. Hooking up a home entertainment system is like throwing darts at a dart board. Or does any one know what all the buttons on your four or five remote controls are used for?

RTFM should never apply to the basic operation of a machine, computer program, or blender. I never got around to learn Emacs editor (even though it gave one geek street cred), as basic operation required you to read the manual. Allow me to explore the program intuitively, and consult the manual for power user features.

The best illustration of a simple and intuitive user interface is the following picture. I've been looking for this picture for a while. It was part of a Steve Jobs' presentation announcing Apple Front Row. In the middle is the Apple remote control: six buttons. To the sides are your standard home entertainment remote controls, include the one used by the Windows Media Center. (Sure a Windows Media Center has TV tuner card recording capability, but do you need all the extra buttons to make use of that feature.)


If there is one thing any engineer should aspire to is to design an incredibly intuitive user interface. Even if it comes at the cost of less feature support, so be it.

Saturday, November 25, 2006

Pinger and Free international calls

I've been experimenting with Pinger the last month. It is a service which allows you to record a message from your phone, to be sent as an mp3.


This is great when you know somebody is in a meeting. Or when you have only a couple of minutes to spare and you don't want to be locked in a long conversation. Think of it like recording memo's.

I discovered the service via TechnCrunch. There is also a short description in a recent technology article from David Pogue in the Wall Street Journal:
FREE ‘PINGS’ Pinger is a new way to reach someone: a method that combines the immediacy of a text message with the personality of voice mail. (You can sign up at Pinger.com.) You call one of Pinger’s access numbers, say the name of the person you’re calling, and then speak a message.

Suppose you’ve just pinged your sister. She receives a text message to let her know. With one keystroke, she can hear your message — and with another, send a voice reply. There’s no waiting to roll over to voice mail, no listening to instructions, no outbound greetings.
But there is something even more interesting in his article: FREE INTERNATIONAL CALLS. That's right! (I haven't tried this yet, until tomorrow that is.)
You can now call any of 50 countries from the United States, free. Talk as long as you like. You pay only for a call to the access number in Iowa, which is 712-858-8883; if you use your cellphone on nights or weekends, even that’s a free call.

There’s no contract, no ads, nothing to sign up for. At the prompt, press 1 for English. Then punch in 011, the country code and the phone number. The call rings through immediately.

Fine print: In some countries, you can reach only landlines, not cellphones. And in part because FuturePhone’s lines have been flooded, its success at placing calls is not, ahem, 100 percent.

But it’s hard to argue with “free,” which, according to the company, it will be until at least 2010.

Wii, Oui Oui Oui

Je deteste le "Black Friday". But here we were, on the famous Friday morning when supposedly many stores become profitable for the year, trolling the local shopping fall for sweatshirts and shoes for the kids at reduced prices. Some of the deals are incredible: 30% / 40% / 50%. It's worth queueing in the parking lot or the standing in line at the stores' check-out (never more than 10 minutes). I was also worth checking out some new consumer products.

In the mall, a team from Nintendo was showcasing the Wii. While Sony and Microsoft are adding more and more triangulation power to the Playstation and Xbox, Nintendo stepped out of the arms race. Instead it took a new and innovative approach with the Wii.


The Wii consists of a base station and a wireless game controller. The Wii is motion sensitive. This is where the genius lies. Pretend the Wii is the handle of a tennisracket and you can partake in an interactive tennis game. Or clasp the Wii controller in your fists and throw some punches in the ring. This a great improvement from the multi-button joystick game controllers giving you a cramp in your thumb.

The Wii might not be very sexy to the hardcore gamer, because of the lack in built-in super computer cpu cycles in the base station. Nevertheless, I predict it will be a great hit among the plebs, because people want more interaction with 'The Machine'. Think of the tetris-like dance step games you find in the arcades. And at half the price of a playstation, it is a much easier gift to buy.

My rating on the Wii: 3 x Oui's !

UPDATE 12/07/2006: The improved user interaction now comes with a "Don't poke fork in eye"-sticker.
"Do not let go of the remote during gameplay. For example, in games like Wii Sports Bowling, the ball is thrown by simply releasing the B Button on the remote, not by letting go of the remote. Hold the remote securely and avoid excessive motion during game play. If your hands become moist, stop and dry your hands." -- Nintendo responds to reports of Wii mishaps with a bit of cautionary advice. (from Good Morning Silicon Valley)
Technorati:

Friday, November 17, 2006

Christmas madness - part one: November

I am not a big fan of the holiday season in the US. It is all about buying buying buying. Shopping malls become madhouses. I know because I used to live across one for two years. Out of the blue, a friend you might meet once a year, will show up with a Christmas gift because you are such great friends. (A better gift would have been to meet for a beer outside of the holiday season.)

It isn't even Thanksgiving yet and the Christmas decorations are out. No, not just in the stores, but in the street. People's houses glow in the light of the Christmas lights. A neighbour across the street already put up her Christmas tree.

Today, while grocery shopping, we came across reversible Christmas wrapping paper. My wife joked: "Have they run out of Christmas ideas?" I just thought there might be light at the end of the Christmas madness tunnel.