Wednesday, October 8, 2008

MEX ing VNL VXL -

VNL is a C++ library to do math with convenient matrix, vector templates and overloaded operators. The next natural thing for me to explore was to write MEX files for MATLAB using VNL. I had tough time forcing CMake to spit out mex files.

Here are the commands that worked for me in x86_64 machine. Let $PREFIX be that path where you installed VXL, ITK, etc.. (/usr/local).


g++ -fPIC -c vnl_code.cpp -I $PREFIX/include/vxl/core -I $PREFIX/include/vcl

# generate a static lib of all your vnl code
ar cqs libvnl_code.a vnl_code.o

mex
-I$PREFIX/include/vxl/core -I$PREFIX/include/vcl -L$PREFIX/lib/ libvnl_code.a mex_wrapper.cpp

Make sure that your C++ code does not have any extern "C" statements. Also, if you are doing this on x86_64, VXL has to be built with -fPIC compiler flag.

Tuesday, April 29, 2008

distcc - distributed compiling

Unfortunately, good amount of software for UNIX is distributed in source format. It's the curse of  the diversity of compatible platforms that UNIX code supports. So yes, we end up compiling the packages first. It can be fun if  you are going for a tailor made tool like those from cron .

Long ago, a friend referred me to distributed compiling.. but never got to check it out. The distributed compiler, named DistCC, turned out to be a cool application. Download, ./configure, make; make install. Here's a quick alias to get you started:
alias startdcc='distccd -j2 -N 10 --daemon --allow 192.168.1.0/24 --user test --verbose --log-file ~/.distcc/logs/distcc_`hostname`.log'

To use try: make -j2 CC=distcc

Saturday, April 26, 2008

user-mode cron

What if you do not have access to cron on your machines ?

I have not explored for schedulers in GNOME/ KDE yet.. but how about getting the source code for CRON and neutering it to work in user-mode. ?? That's what I did.

  • Download the CRON source from here. (Paul Vixie - ISC version 4.1)
  • Edit config.h, Makefile, pathnames.h, macros.h and replace with user defined paths, usernames, etc..
  • Also, generate executable names of your choice like cronuser, crontabuser
  • Compile and run cronuser, crontabuser -e
  • If errors persist, comment code lines related to perror("chown"), setuid, setgid and such until you can use this tool in user-mode.
All this would take 30-40 minutes tops.!!
What to do with it now? Do rsync backups of specific folders, backup your toy DBs, send your self a fortune message or two.. :)

Wednesday, April 23, 2008

Two amazing tools - sqlite, pdftohtml

This week, I had the previlege to use two slick tools. In an attempt to install Django, I had to search for a DB that can be installed in usermode. This led me to SQLite, which is really a zero-config, serverless DB engine as claimed in their site. I was able to create a db in seconds and swiftly setup Django.

Next, those of you who have used latex2html know that you wont get a WYSIWYG job done. I mean the latex2html output is elegant and everything .. but the aesthetics are lost. To that end, my search led to pdftohtml, which stunningly generated HTML code that maintains the same PDF look, more or less. (I have tried simple documents only though)