Saturday, May 12, 2007

Undefined symbols in C++

In C++ programming, we sometimes encounter "undefined symbols" problem during compilation or dlopen. The name of undefined symbols looks obfuscated. E.g.:
Unable to dlopen(test.so): test.so: Undefined symbol "_ZN6moduleD2Ev"
You may wonder why the symbol looks so ugly. Actually, this conversion of symbol is called name mangling. C++ supports polymorphism, this means functions can have same name but different types and numbers of parameters. Therefore, compiler cannot just use the function name as the symbol. Instead, both function name and parameter types should be included in symbol naming. Name mangling is the technique to encode a function name and parameter types into one symbol.

To translate the mangled symbols to more meaningful text, we can use the c++flit utility. E.g.
ahlam@oxygen:~$ c++filt _ZN6moduleD2Ev
module::~module()
Now, you know "_ZN6moduleD2Ev" is the destructor of class module.

Friday, May 11, 2007

More than "command not found"

In old days, if I try to run a command which doesn't exist in my Linux box, it just prompts "command not found". Today, Ubuntu gives me a nice response:
ahlam@oxygen:/usr/bin$ cdecl
The program 'cdecl' can be found in the following packages:
* cutils
* cdecl
Try: sudo apt-get install <selected package>
Make sure you have the 'universe' component enabled
bash: cdecl: command not found

It's surprising!

Wednesday, May 09, 2007

Using new Chinese fonts from M$

One of my friends told me that the Chinese fonts in M$ Vista is much more beautiful. So, I try to install the fonts to my Ubuntu box today. The new Chinese fonts called YaHei and JhengHei. If you don't have Vista, you can download from somewhere (:P). The screenshot below shows the result.


For details about how to install the new fonts, you can refer to http://imtx.cn/feed.php?go=entry_332