Saturday, June 10, 2006

gcc vs. g++: compiler issues

The GCC package contains compilers for several different languages. The extension on the source-file determines which language the compiler will recognise, but the name that you use to invoke the compiler will determine which libraries will be included by default.

With the .cpp extension, your source file will be compiled as a C++
source file. But, by using the name gcc to call the compiler, you are effectively saying that you only need the C libraries. To get the C++ libraries, you should use the name g++: g++ -o test test.cpp

Thursday, April 20, 2006

heap vs. stack

http://c.ittoolbox.com/documents/popular-q-and-a/stack-vs-heap-2112

Traditionally in a process address space you would see stack growing upside down and heap growing upwards. An application wise difference is all the memory allocated dynamically gets allocated on heap viz. malloc free, calloc etc. The stack of an process contains stack frames( containing the return address linkage for a function and the data required in a stack which has the qualifier 'auto').

Efficiency-wise, one thing I can think of is memory on stack should be a bit faster to access as the hit-ratio for the pages having stack memory should have a better chances in terms of cache and also virtual memory. There should be a few more here, which can be same as choice of using array vs new().

The stack is basically a queue which gets (over-)written a lot. It is really intended for function parameters and return codes. Better yet, I would even suggest not having any parameters in functions which are big (for instance a struct or a class).

ALSO: http://www.cnds.jhu.edu/courses/cs111/lect3_600.111/text4.htm

Heap vs. Stack

  • Stack:

    • Grows ‘down’
    • Operations always happen at the top: push and pop, organized
    • It provides support for recursive functions
  • Heap:

    • Grows ‘up’
    • The order in which objects are created/destroyed is totally under the control of the programmer.
    • It is not organized, you can have holes.

Friday, April 14, 2006

xfig issues on Ubuntu Breezy

I was getting a lot of errors on xfig when running, mainly for the font sets available on the system. Here is the problem description and the solution to get it working:
----------------------------------------------------------------------------------
I am having a very strange problem with my xfig installation on Ubuntu Breezy (5.10). I installed the foillowing packages initially:
fig2ps
transfig
fig2sty
xfig
xfig-doc
xfig-libs


When I started xfig after that from a terminal I get this:

Warning: Missing charsets in String to FontSet conversion
Warning: Cannot convert string "-*-times-medium-r-normal--16-*-*-*-*-*-*-*,-*-*-medium-r-normal--16-*-*-*-*-*-*-*,*--16-*" to type FontSet
Warning: Missing charsets in String to FontSet conversion
Warning: Unable to load any usable fontset
Warning: Missing charsets in String to FontSet conversion
Warning: Cannot convert string "-*-times-medium-r-normal--16-*-*-*-*-*-*-*,-*-*-medium-r-normal--16-*-*-*-*-*-*-*,-*-*-*-r-*--16-*-*-*-*-*-*-*" to type FontSet
Warning: Missing charsets in String to FontSet conversion
Warning: Unable to load any usable fontset
Warning: Missing charsets in String to FontSet conversion
Warning: Cannot convert string "-*-times-bold-r-normal--16-*-*-*-*-*-*-*,-*-*-bold-r-normal--16-*-*-*-*-*-*-*,-*-*-*-r-*--16-*-*-*-*-*-*-*" to type FontSet
Warning: Missing charsets in String to FontSet conversion
Warning: Unable to load any usable fontset
Warning: Missing charsets in String to FontSet conversion
Warning: Unable to load any usable fontset

Now the xfig starts, but when I click on *T* for typing text and then click on the figure area, I get this error:

Can't find -*-times-medium-r-normal--13-*-*-*-*-*-ISO8859-*, using 6x13

On a friends recommendation I installed the cyrillic font set as described here:

http://dir.filewatcher.com/d/Ubuntu/....10581772.html

I have no idea what is wrong but I am still gettting the same errors, even after restarting the xfs, restarting X server and even rebooting the machine.

----------------------------------------------------------------------------------

The solution as described in (https://launchpad.net/distros/ubuntu/+source/xfig/+bug/2066) is:

I was able to get rid of these font warnings by doing any of the following:

- "sudo dpkg-reconfigure locales" set default to ISO-8859-1 instead of UTF-8
- put "xset fp rehash" in gnome-session. It must be run after each login.
- run xfig with "LANG=C xfig"

Note: This problems occurs for many of the old X packages. xfontsel, xload, etc.

Friday, February 17, 2006

API vs Library

An API refers to the rules and guidelines and protocols etc that are set forth by a library. In other words, a library has an API. So API is really more of a description of a library, whereas a library is an actual physical chunk of code (well, as physical as code gets).

The easy way to think about this is an API is a specification and the library is an implementation. One API can have many, many implementations. There is Windows and there is WINE for instance. Both implement the Windows GUI APIs.

Wednesday, February 08, 2006

Compiling Perl using ConTEXT on Windows

For executing the perl scripts using custom user commands (I have ActiveState's Perl compiler installed):
  • Go to Options | Environment options... > Execute keys.
  • Press the Add button and type "pl" in the dialog box that appears.
  • Now select one of the function keys (say, F9).
  • Type the full path name to perl.exe in the Execute: box, "%f " in the Parameters: box, and check Capture console output.

Tuesday, February 07, 2006

VMWare 5: USB 2.0 support missing?

VMWare Workstation 5 doesn't support USB 2.0. Although, guest OS can see the USB 2.0 interface through the host, it only allows you to use a USB 1.1 interface while transferring data to a USB attached drive from guest OS.

Ubuntu Breezy: VMWare shared folders not visible in /mnt/hgfs???

I cannot figure out how the shared folders which are supposed to appear in /mnt/hgfs under Ubuntu breezy as a guest OS in VMWare workstation 5.5 would appear. I dont get any errors at all, but it shows me 0 files when I try ls in that folder. Should do some searching to find it.

history.dat file in firefox

I copied the history.dat file from my previous Ubuntu installation (hoary) to a newly created virtual machine (Ubuntu Breezy) and it seems to work fine. I was not sure if this file is somehow encrpted with the default user id created by firefox (something like 3hsdj49348934j ;)

now that it works, it seems the file is just a format not human readable, but definitely an encrypted file, so you can go ahead and clean install your ubuntu with no loss in data or settings (that is if you backup everything)

Ubuntu Breezy: gaim for yahoo pager port #

Pager port: 80 works for me... the default port 5050 doesn't work.

Windows explorer crash opening a folder with "thumbnail" view

I found it to be very annoying when WE was crashing as soon as I try opening a folder (multimedia content) with "thumbnail" preview option set. It is because WE tries to open/run/preview the MM file and thus if the file is corrupt WE will crash.

My SOLUTION:

Just change the view option to list or details :)

the eventual solution is to find the bad file and remove it.

here is something I found on internet while searching for solution:

http://www.moviecodec.com/topics/3588p1.html

1. "Windows XP Explorer has a 'feature' to provide a preview in the Details box on the left of the file you have selected, if it's supported. Image files, HTML pages, video clips, MP3s, etc are all previewed (even with the folder view open).

If you have a large movie clip and it either is corrupt (ie. no index from a partial download) or it uses an unsupported codec, then Explorer tries to load the whole file. This can slow your computer a lot and prevent deleting/renaming/moving/etc the file until it's finished.
Simply do the following steps:
1) Open a command window (Start->Run, type in 'cmd' hit enter)
2) To remove image preview, type and hit enter
regsvr32 /u shimgvw.dll
3) To readd image preview, type and hit enter
regsvr32 shimgvw.dll
4) To remove media preview, type and hit enter
regsvr32 /u shmedia.dll
5) To readd media preview, type and hit enter
regsvr32 shmedia.dll

2. even easier - make two batch files

shmediaoff.bat that has this line in it:
REGSVR32 /U SHMEDIA.DLL

and then shmediaon.bat (to turn preview for files that works) back on:
REGSVR32 SHMEDIA.DLL

3. this also seems to fix the avi problem without having to turn the SHMEDIA.DLL on/off.

http://www.annoyances.org/exec/forum/winxp/t1061425126

registry hack. Run regedit and find the following key :- HKEY_CLASSES_ROOT\SystemFileAssociations\.avi\shellex\PropertyHandler Delete the "Default" value then close. You should now be able to see .avi previews almost instantly but without the crashes.

To use this fix make a new text file, paste the following code in it, file extension change to inf. Rick click on the file and choose install. Done.

[version]
signature="$Windows NT$"

[DefaultInstall]
DelReg = Reduce.Reg

[Reduce.Reg]
HKLM, "SOFTWARE\Classes\CLSID\{87D62D94-71B3-4b9a-9489-5FE6850DC73E}\InProcServer32"
Suggested links:

http://www.tweakxp.com/tweak2123.aspx
http://forums.tech-arena.com/archive/index.php/t-4971.html

hope windows Vista improves on this feature ;)

Monday, February 06, 2006

Welcome

lets get going...