Archive for the ‘Programming’ Category

How to make subclipse plugin working on Eclipse 3.4 Ganymede

Thursday, July 17th, 2008

Recent version of Eclipse 3.4 Ganymede and Subclipse 1.4 plugin doesn’t work out of the box.

I tested on Mac OS X both Leopard and Tiger.

Even after installing <code>svn-javahl</code> package using fink, and adding <code>-Djava.library.path=/sw/lib</code> to eclipse.ini doesn’t work.

Later I installed SVNKit library which was (optional) & “Beta” within Subclipse package, and changed javahl to SVNKit in Preference > Team > SVN.

And it works!

(below note added 7/30)

I realized upgrading svn, svn-client, svn-javahl to version 1.5 or above solve the problem using JavaHL.

Useful 3rd party Eclipse Plugins

Friday, February 15th, 2008

* Subversion Plugin: http://subclipse.tigris.org/

* Python Dev Plugin: http://pydev.sourceforge.net/

Use RDTSC instruction to measure time on x86 architecture

Sunday, September 24th, 2006

In x86 architecture, RDTSC instruction reads current time stamp counter from the hardware. This is a better cost measurement for a program than using GNU time. It’s overhead is low and accuracy is high. You can simply add the following function to get the current counter.

typedef unsigned long long cycles_t;
inline cycles_t currentcycles() {
    cycles_t result;
    __asm__ __volatile__ ("rdtsc" : "=A" (result));
    return result;
}

Autoreconf: One line patch to support multiple include for aclocal

Thursday, August 31st, 2006

A perl script autoreconf is part of GNU autoconf package, which automates the tedious job calling autoconf, autoheader, aclocal, automake, libtoolize, and autopoint appropriately. However, if you have multiple directories for aclocal macros, current 2.6 version of autoreconf doesn’t have a way to do that. This may cause a problem when you build a big software like X where autoreconf is called from a build script, and you have multiple directories to include. However, since it is a mere perl script, the hack is simple. Add one line as below.

	$autoheader .= join (' --prepend-include=', '', @prepend_include);
+	$aclocal   .= ' '.$ENV{'ACLOCAL_FLAGS'};

	# --install and --symlink;
	if ($install)

Now autoreconf will attach flags to aclocal calling it. Hence, you can set ACLOCAL_FLAGS globally which will affect any aclocal call from autoreconf. For example, if you put

export ACLOCAL_FLAGS=”-I /lusr/share/aclocal -I /usr/share/aclocal”

on your ~/.bashrc, autoreconf will use above flags to call aclocal.

You can also modify aclocal since it is also a perl script. It is your choice.

GNU Development Tools (autoconf, automake) Mini Howto

Monday, April 3rd, 2006

If you are programming C/C++ on Linux, it is good to maintain codes with autoconf / automake, because 1) it is easier for you to maintain Makefile & sources & docs 2) others feel comfortable to understand how to build your code 3) it is convenient to distribute source package in this form
Many people think it is not easy to dive into the world of autotools, so here I introduce a simple example.
The example assumes the case where src/ has the source codes.

Create configure.ac

# give any path to the source for sanity check
AC_INIT(src/counter.c)

# For automake
AM_INIT_AUTOMAKE(PROJECT_NAME, VERSION)
AM_CONFIG_HEADER(config.h)

# check for programs (just use that is necessary)
AC_PROG_CC # check for gcc
AC_PROG_CXX # check for g++
AC_PROG_INSTALL # check for install

# check header files
AC_HEADER_STDC

# Output of configure. Usually location of the Makefile to be placed
AC_OUTPUT(Makefile \
src/Makefile )

Create Makefile.am

# file: Makefile
SUBDIRS=src #list of subdirectories (delimiter is space)

# file: src/Makefile
bin_PROGRAMS=prog1 # list of executable to produce (make will create these binaries)
prog1_SOURCES=sourceA.c # list of sources/headers that builds binaryA. This line should be added per bin in $bin_PROGRAMS
prog1_LDADD=-llib1 -llib2 … # (optional) list of libraries for linking prog1
prog1_LDFLAGS= -L/path/to/lib # (optional) linker parameters

# below is global properties
INCLUDES=-I/path/to/include -I/path/to/include2 …
LDADD=-lz -lpthread … # list of libraries

Run autotools

Execute below commands

aclocal
autoheader
autoconf
touch NEWS README AUTHORS ChangeLog
automake -a -c

autoconf creates configure from configure.ac, and automake creates Makefile.in from Makefile.am.

Compile

Now you can follow traditional compiling steps

./configure
make

By default it creates conventional rules in Makefile such as

make clean
make distclean
make install

Also configure has the default options to set the prefix, and other directories

./configure –help

configure creates Makefile from Makefile.in.

Maintaining the codes

Adding a source code
Modify the Makefile.am in the same directory where the new sources are placed. Then run automake
Adding a directory
Modify configure.ac (AC_OUTPUT), and add Makefile.am to the new directory. Then run autoconf, and automake

References

For more detail:

Make Transparent PNG Transparent in IE

Friday, February 3rd, 2006

Somehow, IE doesn’t handle PNG correctly.

Here is the workaround.
http://www.alistapart.com/articles/pngopacity