HaukeHeibelDevelopment

Chair for Computer Aided Medical Procedures & Augmented Reality
Lehrstuhl für Informatikanwendungen in der Medizin & Augmented Reality

Development

Pimping the Visual Studio Debug Output

When you want to do proper debugging in Visual Studio and you are using boost's uBlas library or our NuDe library, you might want to copy the following data to the file autoexp.dat in the folder <MS Visual Studio Dir>/Common7/Packages/Debugger.

The file autoexp.dat contains two different section, namely [Visualizer] and [AutoExpand]. It is important that the provided scripts go not to the end of the file but into the section [Visualizer].

; ---------------------------------- snip ----------------------------------
NuDe::Vector<*,NuDe::StackVector<2> >{
   children
   (
      #(
         x : ($c.m_vec.data_.data_)[0],
         y : ($c.m_vec.data_.data_)[1]
      )
   )

   preview
  (
     #(
      "(",

         #array
      (
            expr :    [($c.m_vec.data_.data_)[$i],g],
            size :    $c.m_vec.data_.size_
         ),
         ")"
      )
   )
}

NuDe::Vector<*,NuDe::StackVector<3> >{
   children
   (
      #(
         x : ($c.m_vec.data_.data_)[0],
         y : ($c.m_vec.data_.data_)[1],
         z : ($c.m_vec.data_.data_)[2]
      )
   )

   preview
  (
     #(
      "(",

         #array
      (
            expr :    [($c.m_vec.data_.data_)[$i],g],
            size :    $c.m_vec.data_.size_
         ),
         ")"
      )
   )
}

NuDe::Vector<*,NuDe::StackVector<*> >{
   children
   (
      #array
     (
         expr :   ($c.m_vec.data_.data_)[$i],
         size :   $c.m_vec.data_.size_
      )
   )

   preview
   (
     #(
         "[",
      $c.m_vec.data_.size_ ,
      "](",

         #array
      (
            expr :    [($c.m_vec.data_.data_)[$i],g],
            size :    $c.m_vec.data_.size_
         ),
         ")"
      )
   )
}

NuDe::Vector<*, NuDe::HeapStorage>{
   children
   (
      #array
     (
         expr :   ($c.m_vec.data_.data_)[$i],
         size :   $c.m_vec.data_.size_
      )
   )

   preview
  (
     #(
         "[",
      $c.m_vec.data_.size_ ,
      "](",

      #array
      (
            expr :    [($c.m_vec.data_.data_)[$i],g],
            size :    $c.m_vec.data_.size_
         ),
         ")"
      )
   )
}

NuDe::Matrix<*,NuDe::StackMatrix<*,*> >{
  children
   (
      #(
         [ublas]: [$c.m_mat,!],
         rows: $c.m_mat.size1_,
         cols: $c.m_mat.size2_,
         #array(
            expr: ($c.m_mat.data_.data_)[$i],
            size: ((unsigned int*)(&($c.m_mat.size1_)))[$r],
            rank: 2
         )
      )
   )

   preview
   (
     #(
         "[",
      $c.m_mat.size1_,
      ",",
      $c.m_mat.size2_,
      "](",

         #array
      (
            expr :    [($c.m_mat.data_.data_)[$i],g],
            size :    $c.m_mat.data_.size_
         ),
         ")"
      )
   )
}

NuDe::Matrix<*,*>{
   children
   (
      #(
         [ublas]: [$c.m_mat,!],
         rows: $c.m_mat.size1_,
         cols: $c.m_mat.size2_,
         #array(
            expr: ($c.m_mat.data_.data_)[$i],
            size: ((unsigned int*)(&($c.m_mat.size1_)))[$r],
            rank: 2
         )
      )
   )

   preview
   (
      #(
         "[",
         $c.m_mat.size1_ ,
         ",",
         $c.m_mat.size2_ ,
         "](",

         #array
         (
            expr : [($c.m_mat.data_.data_)[$i],g],
            size : $c.m_mat.data_.size_
         ) ,
         ")"
      )
   )
}

boost::numeric::ublas::bounded_vector<*,*>{
   children
   (
      #array
     (
         expr :   ($c.data_.data_)[$i],
         size :   $c.data_.size_
      )
   )

   preview
   (
     #(
         "[",
      $c.data_.size_ ,
      "](",

         #array
      (
            expr :    [($c.data_.data_)[$i],g],
            size :    $c.data_.size_
         ),
         ")"
      )
   )
}

boost::numeric::ublas::vector<*,*>{
   children
   (
      #array
     (
         expr :   ($c.data_.data_)[$i],
         size :   $c.data_.size_
      )
   )

   preview
  (
     #(
         "[",
      $c.data_.size_ ,
      "](",

      #array
      (
            expr :    [($c.data_.data_)[$i],g],
            size :    $c.data_.size_
         ),
         ")"
      )
   )
}

boost::numeric::ublas::bounded_matrix<*,*,*,*>{
   children
   (
      #(
         [raw members]: [$c,!],
         rows : $c.size1_,
         cols : $c.size2_,
         #array(
            expr: ($c.data_.data_)[$i],
            size: ((unsigned int*)(&($c.size1_)))[$r],
            rank: 2
         )
      )
   )

   preview
   (
      #(
         "[",
         $c.size1_ ,
         ",",
         $c.size2_ ,
         "](",

         #array
         (
            expr : [($c.data_.data_)[$i],g],
            size : $c.data_.size_
         ) ,
         ")"
      )
   )
}

;
boost::numeric::ublas::matrix<*,boost::numeric::ublas::basic_row_major<*,*>,*>{
   children
   (
      #(
         [raw members]: [$c,!],
         rows: $c.size1_,
         cols: $c.size2_,
         #array(
            expr: ($c.data_.data_)[$i],
            size: ((unsigned int*)(&($c.size1_)))[$r],
            rank: 2
         )
      )
   )

   preview
   (
      #(
         "[",
         $c.size1_ ,
         ",",
         $c.size2_ ,
         "](",

         #array
         (
            expr : [($c.data_.data_)[$i],g],
            size : $c.data_.size_
         ) ,
         ")"
      )
   )
}

boost::numeric::ublas::matrix<*,boost::numeric::ublas::basic_column_major<*,*>,*>{
   children
   (
      #(
         [raw members]: [$c,!],
         cols: $c.size1_,
         rows: $c.size2_,         
         #array(
            expr: ($c.data_.data_)[$i],
            size: ((unsigned int*)(&($c.size1_)))[$r],
            rank: 2
         )
      )
   )

   preview
   (
      #(
         "[",
         $c.size1_ ,
         ",",
         $c.size2_ ,
         "](",

         #array
         (
            expr : [($c.data_.data_)[$i],g],
            size : $c.data_.size_
         ) ,
         ")"
      )
   )
}
; ---------------------------------- snap ----------------------------------

Compiling Atlas 3.8.2

Notes:

  • Requires a Cygwin installation with g77/gcc
  • This is more or less intended for me, so I do not loose this information
  • You must not put ATLAS into a directory containing whitespaces
  • In my experience compiling with VS.Net does not have any advantages

Directory abbreviations:

<CYG_DIR>.... The Cygwin base installation directory
<VIS_DIR>.... The Visual Studio .Net install directory
<LAP_DIR>.... The LAPACK (not CLAPCKI) source directory
<SRC_DIR>.... The ATLAS source directory
<BLD_DIR>.... The actual build directory of the atlas libraries

Preparing the Visual Studio Compiler:

1. Edit <CYG_DIR>/Cygwin.bat such that it configures the VS.Net environment variables.
@echo off
chdir c:\Program Files\Microsoft Visual Studio 8\VC
call vcvarsall
C:
chdir C:\Cygwin\bin
bash --login -i

Building ATLAS with full LAPACK (Fortran interace):

1. Start Cygwin, go to <SRC_DIR> and type
homer> mkdir bogus
homer> cd bogus
homer> ../configure -b 32 -D c -DPentiumCPS=2160 -Si nocygwin 1
... configure output ...
homer> fgrep "F77 =" Make.inc
   F77 = g77
homer> fgrep "F77FLAGS =" Make.inc
   F77FLAGS = -O -m32 -mno-cygwin

2. Switch back to Windows, copy <LAP_DIR>/make.inc.example to <LAP_DIR>/make.inc and start editing it. The important entries should now look like (conforming to the build parameters ATLAS is going to use):
FORTRAN  = g77 
OPTS     = -O -m32 -mno-cygwin
DRVOPTS  = $(OPTS)
NOOPT    = -m32 -mno-cygwin
LOADER   = $(FORTRAN)
LOADOPTS = $(OPTS)

3. Go back to Cygwin and build LAPACK
homer> cd <LAP_DIR>
homer> make lib
... build output ...
homer> ll
...
-rw-r--r--  1 Hauke None 4989886 Jun 27 23:19 lapack_LINUX.a
...
There we go, the lapack lib (lapack_LINUX.a) is readily built.

4. Go back to ATLAS, clean up and perform the actual build
homer> cd <SRC_DIR>
homer> rm -rf bogus
homer> mkdir homer32vs
homer> cd homer32vs
homer> ../configure -b 32 -D c -DPentiumCPS=2160 -Si nocygwin 1 \
  --prefix=/home/hauke/external/atlas \
  --with-netlib-lapack=/home/hauke/source/netlib/lapack/lapack_LINUX.a
...  configuration output ...
homer> make
... make output (go 'n grab a coffee) ...

Compiling Fortran Code into a Library

In the Cygwin shell (bash or whatever you have) go to the diretory containing the Fortran code and type

g77 -mno-cygwin -O3 -c *.f

This will create a lot of object files. These object files can now be put together in a static library with the help of lib.exe from VS.Net. So we open the "Visual Studio Command Prompt" and move once more to the directory containing the Fortran code and now also the object files. The library is created by typing

lib *.o /out:mylibrary.lib

That's all...

Links of stupid errors

Qt Convenience Macro

This little macro allows you to add the Qt mocing process as a custom build step to your Qt header file. The script automatically adds the information to all build configurations and creates the .cpp file relative to your header file, i.e. in this case ../src. Assuming your header file is located in include/MyQtHeader.h, the moced file will be located at src/moc_MyQtHeader.h.

To integrate the macro into your Visual Studio hit ALT+F11 in you IDE. This should bring up the Macro IDE. In the macro IDE double-click on MyMacros. You can now modify existing dummy modules or create a new module via MyMacros->Add->AddModule. Be sure that the module's name is equal to QtModule. Now you just need to paste the code below into your module and save it. The final step is to add the missing references to Microsoft.VisualStudio.VCProject and Microsoft.VisualStudio.VCProjectEngine. That's it. You can now close the Macro IDE after saving everything.

Back within your normal VS IDE, create yourself a new toolbar (this is done via the Customize... option from the toolbar context menu). Your new macro can be found in the Commands tab under the category Macros (it might require a restart but I am not sure).

When you execute the macro, it will be applied to the opened file currently being active. No checking against the Q_OBJECT macro is done, so its up to you to check that.

After having built your project once, check the location of your moc_*.cpp file and add it to your project.

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports Microsoft.VisualStudio.VCProjectEngine


Public Module QtMacros
    Sub AddQtMocCustomBuildStep()
        Dim doc As Document = DTE.ActiveDocument
        Dim docname As String = doc.Name.ToLower
        Dim project As Project = doc.ProjectItem.ContainingProject

        ' applies only to C/C++ projects
        If doc.Language = "C/C++" Then
            If docname.EndsWith(".h") Then

                Dim vcproj As VCProject = project.Object
                Dim projfiles As IVCCollection = vcproj.Files
                Dim vcfile As VCFile = Nothing

                ' find the file in current project
                For Each f As VCFile In projfiles
                    If f.Name = doc.Name Then
                        vcfile = f
                        Exit For
                    End If
                Next

                ' apply the modication to all configurations that are available
                Dim fileConfigurations As IVCCollection = vcfile.FileConfigurations

                For Each fileConfig As VCFileConfiguration In fileConfigurations
                    Dim vcConfig As VCConfiguration = vcproj.Configurations(fileConfig.Name)
                    fileConfig.Tool = vcConfig.Tools("VCCustomBuildTool")
                    fileConfig.Tool.Description = "Running MOC on $(InputName)"
                    fileConfig.Tool.CommandLine = """$(CAMP3RDPARTY)/Qt/bin/moc.exe"" -I""$(CAMP3RDPARTY)/Qt/include"" ""$(InputPath)"" -o ""$(InputDir)/../src/moc_$(InputName).cpp"""
                    fileConfig.Tool.Outputs = """$(InputDir)/../src/moc_$(InputName).cpp"""
                Next

            End If
        End If
    End Sub

    Sub AddQtUICustomBuildStep()
        Dim doc As Document = DTE.ActiveDocument
        Dim docname As String = doc.Name.ToLower
        Dim project As Project = doc.ProjectItem.ContainingProject

        ' applies only to C/C++ projects
        If doc.Language = "XML" Then
            If docname.EndsWith(".ui") Then

                Dim vcproj As VCProject = project.Object
                Dim projfiles As IVCCollection = vcproj.Files
                Dim vcfile As VCFile = Nothing

                ' find the file in current project
                For Each f As VCFile In projfiles
                    If f.Name = doc.Name Then
                        vcfile = f
                        Exit For
                    End If
                Next

                ' apply the modication to all configurations that are available
                Dim fileConfigurations As IVCCollection = vcfile.FileConfigurations

                For Each fileConfig As VCFileConfiguration In fileConfigurations
                    Dim vcConfig As VCConfiguration = vcproj.Configurations(fileConfig.Name)
                    fileConfig.Tool = vcConfig.Tools("VCCustomBuildTool")
                    fileConfig.Tool.Description = "Running UI on $(InputName)"
                    fileConfig.Tool.CommandLine = """$(CAMP3RDPARTY)/Qt/bin/uic.exe"" ""$(InputPath)"" -o ""$(InputDir)/../include/ui_$(InputName).h"""
                    fileConfig.Tool.Outputs = """$(InputDir)/../include/ui_$(InputName).h"""
                    fileConfig.Tool.AdditionalDependencies = """$(InputPath)"""
                Next

            End If
        End If
    End Sub
End Module

Dealing with the OpenCV CVS snapshot

OpenCV should compile right away without any project file tweaks. Once you are done, feel free to use the batch script provided on this site to copy all required files to the Janus file server.

Dealing with Boost SVN snapshots

This mini tutorial starts assuming you have the current version SVN snapshot of the Boost libraries checked out to your hard disk. For the remainder of the tutorial I will for sake of simplicity refer to this folder as %BOOST_ROOT%.

Compilation and installation of BJam

The first step of the installation deals with the compilation of BJam which is required in turn to compile and install the Boost libraries. To install BJam change to the directoy %BOOST_ROOT%/tools/src. If you have bad luck you might need to edit build.jam to properly build a multi threaded version of BJam (libc.lib is not supported any more in Visual Studio .Net 2005), i.e. you need to set the proper build flags according to your compiler. In case of the Intel Compiler, the flags /MT and /MTd need to be replaced by /ML and /MLd. Once everything is configure, you simply need to execute the batch file build.bat. The last step is to switch to the directory %BOOST_ROOT%/tools/src/bin.netx86 and copy the bjam.exe just flat into your %BOOST_ROOT%.

Thats was it for getting BJam up and running and we can now safely continue with compiling and installing the actual Boost libraries.

Compilation and installation of the Boost libraries

At first we switch to the directory %BOOST_ROOT% in which the current SVN snapshot is located.

Some of the Boost libraries are not simple template header files but require actual object code to work. We choose to compile the libraries as dynamic libraries which will yield a .lib and a .dll file for each library. Currently (Sept. 2007) we are just using the following set of Boost libraries:

  • Graph
  • IOStreams
  • Program Options
  • RegEx
  • Serialization
  • Signals
  • System
  • Thread
  • Wave

The proper BJam flags that are required to build boost properly are:

Parameter Effect
--with-graph Explicitly build the graph library.
--with-iostreams Explicitly build the iostreams library.
--with-program_options Explicitly build the program options library.
--with-regex Explicitly build the regex library.
--with-serialization Explicitly build the serialization library.
--with-signals Explicitly build the signals library.
--with-system Explicitly build the system library.
--with-thread Explicitly build the thread library.
--with-wave Explicitly build the wave library.
variant=debug/release Force building debug respectively release versions of the libraries.
threading=multi Force to build multi-threaded libraries.
link=shared Force to build dynamic libraries.
stage Copy object and other intermediate files to the directory %BOOST_ROOT%/stage.
install Install the header and library files to c:/boost/.

After the Boost library has been completely build, copy the data from c:/boost/include/boost[version]/boost to //Janus/3rdparty/boost/boost and the data from c:/boost/lib to //Janus/3rdparty/boost/lib.

Grepping for Symbols

#!/bin/bash
UNDNAME="`cygpath -a "$PROGRAMFILES"`/Microsoft Visual Studio 8/VC/bin/undname.exe"
SYMBOL=$1
shift
for i in $*
    do
    OUT=(`nm $i | grep -v "^[0-9a-f ][0-9a-f ][0-9a-f ][0-9a-f ][0-9a-f ][0-9a-f ][0-9a-f ][0-9a-f ] [Utr]" | grep $SYMBOL `)
    if [ "${OUT[0]}" != "" ] ; then
        echo $i
        if [ -a "$UNDNAME" ] ; then
            for (( i = 0 ; i < ${#OUT[*]} ; i += 3 )) ; do
                j=$[$i+1]
                k=$[$i+2]
                echo ${OUT[$i]} ${OUT[$j]} ${OUT[$k]} `"$UNDNAME" ${OUT[$k]} | grep "is :-" | sed 's/^is :- //g'`
            done
        else
            echo $OUT
        fi
    fi
done

I Attachment sort Action Size Date Who Comment
camp-boost-bjam.bat manage 0.8 K 24 Sep 2007 - 10:16 HaukeHeibel The batch file with proper BJam parameters for the CAMP library.
camp-opencv.bat manage 0.6 K 24 Sep 2007 - 11:57 HaukeHeibel The batch file for copying all required files to the Janus file server.

Edit | Attach | Refresh | Diffs | More | Revision r1.27 - 20 Oct 2008 - 08:10 - HaukeHeibel

Lehrstuhl für Computer Aided Medical Procedures & Augmented Reality    rss.gif