User talk:Mathieu

From KitwarePublic
Jump to navigationJump to search

Linux

I use Linux. The main reasons are stability and ease of use (I love shells !).

Links:


Debian

Debian is really cool, you have access to billions of package one command line away. The very last package I discover is gcc-snapshot:


 http://packages.debian.org/unstable/devel/gcc-snapshot

Basically you have access to gcc4.0 (+fortran !!) with no hassle. another cool stuff is that gcj comes with libjawt (jawt.h ...) can't wait to compile VTK using gcj.

gVim

Tip #312: Copy, Cut, and Paste

Link I always loose

Zsh

Zsh simply rocks, there absolutely no reason not to switch to zsh from bash since it support all the bash command and is better:

Similarities with bash

Also read From Bash to Z Shell: Conquering the Command Line

Some usefull zsh command:

Eventhought it should be possible to set zsh to behave like vim with 'set -o vi', I am used to the 'emacs' style command in zsh:

Ctrl+a : Start of line
Ctrl+e : End of line
Ctrl+l : Clean screen
Ctrl+u : Delete anything
Ctrl+w : Delete anything on the left side of cursor
Ctr+r  : Historic search
Ctrl+y : Paste buffer
Ctrl+d : delete active character or disconnect if empty line
Alt+b / Alt+f : jump from one word to the other
Ctrl+Backspace (Ctrl+w) : erase previous work
Alt+d : delete next work
Alt+t : exhcange current word and next one
Alt+c : capitalize current letter, and uncapitalize the next letter, and jump to the end of word
Ctrl+t : exchange two letters

UNIX shell differences and how to change your shell

Copy paste from: http://www.faqs.org/faqs/unix-faq/shell/shell-differences/

                                     sh   csh  ksh  bash tcsh zsh  rc   es
Job control                          N    Y    Y    Y    Y    Y    N    N
Aliases                              N    Y    Y    Y    Y    Y    N    N
Shell functions                      Y(1) N    Y    Y    N    Y    Y    Y
"Sensible" Input/Output redirection  Y    N    Y    Y    N    Y    Y    Y
Directory stack                      N    Y    Y    Y    Y    Y    F    F
Command history                      N    Y    Y    Y    Y    Y    L    L
Command line editing                 N    N    Y    Y    Y    Y    L    L
Vi Command line editing              N    N    Y    Y    Y(3) Y    L    L
Emacs Command line editing           N    N    Y    Y    Y    Y    L    L
Rebindable Command line editing      N    N    N    Y    Y    Y    L    L
User name look up                    N    Y    Y    Y    Y    Y    L    L
Login/Logout watching                N    N    N    N    Y    Y    F    F
Filename completion                  N    Y(1) Y    Y    Y    Y    L    L
Username completion                  N    Y(2) Y    Y    Y    Y    L    L
Hostname completion                  N    Y(2) Y    Y    Y    Y    L    L
History completion                   N    N    N    Y    Y    Y    L    L
Fully programmable Completion        N    N    N    N    Y    Y    N    N
Mh Mailbox completion                N    N    N    N(4) N(6) N(6) N    N
Co Processes                         N    N    Y    N    N    Y    N    N
Builtin artithmetic evaluation       N    Y    Y    Y    Y    Y    N    N
Can follow symbolic links invisibly  N    N    Y    Y    Y    Y    N    N
Periodic command execution           N    N    N    N    Y    Y    N    N
Custom Prompt (easily)               N    N    Y    Y    Y    Y    Y    Y
Sun Keyboard Hack                    N    N    N    N    N    Y    N    N
Spelling Correction                  N    N    N    N    Y    Y    N    N
Process Substitution                 N    N    N    Y(2) N    Y    Y    Y
Underlying Syntax                    sh   csh  sh   sh   csh  sh   rc   rc
Freely Available                     N    N    N(5) Y    Y    Y    Y    Y
Checks Mailbox                       N    Y    Y    Y    Y    Y    F    F
Tty Sanity Checking                  N    N    N    N    Y    Y    N    N
Can cope with large argument lists   Y    N    Y    Y    Y    Y    Y    Y
Has non-interactive startup file     N    Y    Y(7) Y(7) Y    Y    N    N
Has non-login startup file           N    Y    Y(7) Y    Y    Y    N    N
Can avoid user startup files         N    Y    N    Y    N    Y    Y    Y
Can specify startup file             N    N    Y    Y    N    N    N    N
Low level command redefinition       N    N    N    N    N    N    N    Y
Has anonymous functions              N    N    N    N    N    N    Y    Y
List Variables                       N    Y    Y    N    Y    Y    Y    Y
Full signal trap handling            Y    N    Y    Y    N    Y    Y    Y
File no clobber ability              N    Y    Y    Y    Y    Y    N    F
Local variables                      N    N    Y    Y    N    Y    Y    Y
Lexically scoped variables           N    N    N    N    N    N    N    Y
Exceptions                           N    N    N    N    N    N    N    Y

Key to the table above.

   Y      Feature can be done using this shell.
          
   N      Feature is not present in the shell.
          
   F      Feature can only be done by using the shells function
          mechanism.
          
   L      The readline library must be linked into the shell to enable
          this Feature.
          
Notes to the table above

    1. This feature was not in the orginal version, but has since become
       almost standard.
    2. This feature is fairly new and so is often not found on many
       versions of the shell, it is gradually making its way into
       standard distribution.
    3. The Vi emulation of this shell is thought by many to be
       incomplete.
    4. This feature is not standard but unoffical patches exist to
       perform this.
    5. A version called 'pdksh' is freely available, but does not have
       the full functionality of the AT&T version.
    6. This can be done via the shells programmable completion mechanism.
    7. Only by specifing a file via the ENV environment variable.

Other link to documentation:

Mac OSX

Some tricks I always forgot on MacOSX:

ldd -> otools -L

strace/ltrace -> ktrace / kdump

Configuring and running X11 on MacOSX


older MacOS

Building without backward compatibility

By default the build system will always build in backward compatiblity. Therefore in order to test new functionality (link against newer version) and get the proper warnings you need to do the following.

In you CMakeCache.txt you need to have:

CMAKE_CXX_FLAGS                  -DMAC_OS_X_VERSION_MAX_ALLOWED=1030
CMAKE_C_FLAGS                    -DMAC_OS_X_VERSION_MAX_ALLOWED=1030

and type

export MACOSX_DEPLOYMENT_TARGET=10.3

before the make command.

Setting up a dashboard

On my mac mini I wanted to keep the screen saver, the sleep and automatic power-down. But also I wanted to be able to run a dashboard, a perfect solution is:

[cronwake] http://homepage.mac.com/nand/macosx/cronwake-README.html

Installing Tcl/Tk/Python on MacOSX

Basically taken from: http://www.astro.washington.edu/owen/PythonOnMacOSX.html

Go to: http://www.apple.com/downloads/macosx/unix_open_source/tcltkaqua.html Then: http://homepages.cwi.nl/~jack/macpython/

Then tkinter might not be installed, you need to check with PackageManager: /Application/MacPython*/PackageManager

if URL is broken copy paste URL from: http://www.python.org/packman/

Automatic Startup On MacOS X

How can I make a program start automatically after I login to MacOS X? (Or when the computer starts if MacOS logs in automatically.)

  1. Open "System Preferences" (this should be in the Dock at the bottom of the screen).
  2. Click "Accounts".
  3. Click the "Startup Items" tab.
  4. Click the "+" button.
  5. Navigate to the program you want to be automatically started.
  6. Click the "Add" button. That should be all you need to do.
  7. Optional: If you want the program to be hidden after it is started, click the tick box in the "Hide" column.


X11 on MacOSX

to start X11

 open -a X11

You may find the 'open-x11' command useful. 'man open-x11'.

The open-x11 that comes with OS X is a bit limited, so I rewrote it: http://xanana.ucsc.edu/Library/init/zsh/local-functions/darwin/open-x11

Valgrind

gdb and valgrind

some valgrind 'feature' to gdb an unitialized var you need to use valgrind macro:

From [How to output address of the unitialized value? ]

Your best bet in that case is to inspect the code at the failing location and see if there is an obvious cause, and if not then to try inserting some assertions using the valgrind macros to try and work out what is uninitialised - assertions like this will do it:

  assert( !VALGRIND_CHECK_READABLE( &variable, sizeof( variable ) ) );


file open and valgrind

You can track how many files are open when your programm terminates if you use the flag (works only with recent valgrind version):

 --track-fds=yes

Another approach is to use:

 strace -eopen


space in the patch and valgrind

http://bugs.kde.org/show_bug.cgi?id=88678

[When the path of the executable (built with gcc -g option) contains a (properly escaped) space character, the functions from that executable are not properly displayed in the stack trace. Instead ??? marks are printed as if the executable had no debug info. ]

GDB

Yet another trick for debugging the destructor of a class: Steps:

 nm --defined-only -C vtkEnSight6Reader.o | grep '~'

copy the hexadecimal for those symbol then do

 nm --defined-only vtkEnSight6Reader.o | grep 'my_symbol'

then you just need to add a breakpoint on that particular symbol, repeat if more than one destructor.


CMake

Another trick when writting regex in CMake, look at:

http://www.aivosto.com/vbtips/regex.html

It's fairly well describe


Xvfb

How to run a VTK dashboards without window poping up (using Xvfb):

sudo apt-get install xvfb
Xvfb :9 -ac  -screen 0 300x300x24
export DISPLAY=:9
ctest -D Experimental

Links: http://lists.debian.org/debian-user/2004/11/msg02220.html

just for the archive: found the solution on the net, the file named by -auth should simply contain host names in cleartest. In my case I made a file
/etc/X99.cfg
containing the single line:
localhost
and call Xvfb thus:
Xvfb :86 -auth /etc/X99.cfg -screen scrn 800x600x32 &


xvfb could not init font path element usr x11r6 lib x11 fonts cid removing list

Clean way to start/stop Xvfb

Better user Xvfb.

Depending on the distribution you use you can
place a start script like this in /etc/init.d or 
/etc/rc.d/init.d to start xvfb.

XVFB=/usr/X11R6/bin/Xvfb
XVFBARGS=":99 -screen 0 1024x768x24 -fbdir /var/run -ac"
PIDFILE=/var/run/xvfb.pid
case "$1" in
  start)
    echo -n "Starting virtual X frame buffer: Xvfb"
    start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile
--background --exec $XVFB -- $XVFBARGS
    echo "."
    ;;
  stop)
    echo -n "Stopping virtual X frame buffer: Xvfb"
    start-stop-daemon --stop --quiet --pidfile $PIDFILE
    echo "."
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  *)
        echo "Usage: /etc/init.d/xvfb {start|stop|restart}"
        exit 1
esac

exit 0

This is what we use for debian.
:99 is the value for the xserver id that must be set 
in the DISPLAY env.

DISPLAY=localhost:99.0

Additionaly you have to define a link in /etc/rc?.d to this file
for the run levels where you need the Xvfb. (This is for debian,
other distributions 

Xvfb

Running your dashboard with Xvfb (=a quick way to have an offscreen dashboard).

 sudo apt-get install xvfb
 Xvfb :99 -screen scrn 300x300x24 -ac -fbdir /tmp
 export DISPLAY=:99
 ctest -D Experimental

You can look what is going on with:

 xwd -root -display :98 | xwud 

I could not find any way to directly look at

  xwud -in /tmp/Xvfb_screen0

xwud only works with 8bits...

A nice script for your dashboard to specify different screen for each dashboard (no need to be root !):

#! /bin/sh
# Startup script for Xvfb (also to stop it properly)
# Found on: http://marc.theaimsgroup.com/?l=tomcat-user&m=102335321103262&w=2

XVFB=/usr/X11R6/bin/Xvfb
#XVFBARGS=":99 -screen 0 1024x768x24 -fbdir /var/run -ac"
XVFBARGS=":$2 -screen 0 1024x768x24 -fbdir /tmp -ac"
echo $XVFBARGS
#PIDFILE=/var/run/xvfb.pid
PIDFILE=/tmp/xvfb$2.pid

case "$1" in
  start)
    echo -n "Starting virtual X frame buffer: Xvfb"
    /sbin/start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
    echo "."
    ;;
  stop)
    echo -n "Stopping virtual X frame buffer: Xvfb"
    /sbin/start-stop-daemon --stop --quiet --pidfile $PIDFILE
    echo "."
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "Usage: xvfb {start|stop|restart}"
    exit 1
esac

exit 0


ATI (fglrx)

For some reason seems to work outof the box, no need for the LIBGL_ALWAYS_INDIRECT=1 magic...

NVidia

Couldn't get the thing to work. I had to use Mesa instead. For some reason

 ctest -R Mace

Was only working for the first Mace but breaking on the second with:

X Error of failed request:  BadAlloc (insufficient resources for operation)
  Major opcode of failed request:  147 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Serial number of failed request:  35
  Current serial number in output stream:  36

I solved it using LD_PRELOAD=/opt/Mesa/lib/libGL.so

Insight Journal

Need to fix InsightJournal cls/sty sutff:

hyperref knows the option `pdfusetitle', then it tries to use the maketitle data for the PDF document information.

http://groups.google.com/group/comp.text.tex/browse_frm/thread/d4699f4d411036a0/b0e50854e04a818b#b0e50854e04a818b

Stuff TODO

- I need to setup a guide to cross compile VTK on debian


- I ................... install intel icc on debian linux (all versions)


http://www.atai.org/guitool/

I still canot boot into BeOS using grub:


Keep an eye on svn:

[ugly problem found while trying to test KDE SVN] http://svn.haxx.se/dev/archive-2005-02/0897.shtml

[How do you tell the compiler to make a member function inline?] http://www.parashift.com/c++-faq-lite/inline-functions.html#faq-9.7

Borland:


Add a proper steps to install Free C++ Tools (with libcmtd.lib), copy/paste stuff from:

http://wiki.wxwidgets.org/wiki.pl?Installing_WxWin_For_MS_Free_Tools

Also add ctest example


New gcc optimization: http://www.onversity.com/cgi-bin/progactu/actu_aff.cgi?Eudo=bgteob&P=N200310#070 -> http://gcc.gnu.org/projects/tree-ssa/vectorization.html


Add some note about option with icc:

http://www.intel.com/software/products/compilers/clin/docs/ug_cpp/lin1177.htm http://www.theochem.uwa.edu.au/fortran/intel_on_debian/mpich

in particular: -cxxlib-icc

Here is my ./icc81 script (debian testing with gcc3.3):

export CC=/opt/intel_cc_8.1/bin/icc
export CXX=/opt/intel_cc_8.1/bin/icpc
export LD_LIBRARY_PATH=/opt/intel_cc_8.1/lib
export GXX_INCLUDE=/usr/include/c++/3.3
export CXXFLAGS='-Wall -Wno-deprecated -wd1572,981,383,1418,810,1419,424'
export CFLAGS='-Wall -wd810,981,279,593,1418'


VTK / FFMPEG

 sudo apt-get install ffmpeg
 sudo apt-get install libffmpeg0
 sudo apt-get install libavcodec-dev
 sudo apt-get install libavformat-dev


RAV