[vtkusers] Re: VTK & VC++ without CMake (Jarno Ahma)

Ed Hill ed at eh3.com
Mon Jul 9 23:09:41 EDT 2007


On Mon, 9 Jul 2007 13:22:13 -0400 "Steve Chall" wrote:

> > is it possible to create C++ codes using vtk's static 
> > libraries without CMake? And if so, how?
> 
> I'm running on Linux.  Please find below a command-line call to the
> g++ compiler, in which I build an executable "ss" by , among other
> things, compiling the .cxx files for a couple of subclasses of VTK
> classes I've written, along with my primary application-specific
> class (implemented in ss.cxx), and my main program (main.cxx).  I run
> this as (part of) a bash shell script.
> 
> -Steve
> 
> g++ -Wno-deprecated -I/usr/include/vtk-5.0 -o ss
> ssInteractorStyleTrackballCamera.cxx ssXRenderWindowInteractor.cxx
> ss.cxx main.cxx /usr/lib/libvtkGraphics.so  /usr/lib/libvtkCommon.so
> -L /usr/X11R6/lib -lGL -lXt -lX11 /usr/lib/libvtkImaging.so
> /usr/lib/libvtkRendering.so


If you like the auto-tools (autoconf, automake, etc.) then you can
write some quick tests for the availability/usability of various VTK
headers, libs, etc. in your configure.ac file.  An example follows.

Ed

#===  configure.ac snippet

AC_MSG_CHECKING([for VTK header vtkCubeSource.h])
AC_COMPILE_IFELSE(
    [AC_LANG_PROGRAM(
        [[
#include "vtkCubeSource.h"
#include "vtkCylinderSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkCamera.h"
        ]],
        [[
  //  Cube
  //
  vtkCubeSource * cube = vtkCubeSource::New();
  cube->SetCenter(2.0,0.0,0.0);
  vtkPolyDataMapper * cubeMapper = vtkPolyDataMapper::New();
  cubeMapper->SetInputConnection(cube->GetOutputPort());
  vtkActor * cubeActor = vtkActor::New();
  cubeActor->SetMapper(cubeMapper);
  cubeActor->GetProperty()->SetColor(0.5, 1.000, 0.5);
        ]])],
        AC_MSG_RESULT(yes),
        [ AC_MSG_RESULT(no);
          AC_MSG_ERROR([missing VTK headers!])])
save_LIBS="$LIBS"; LIBS="-lvtkRendering $LIBS";
AC_MSG_CHECKING([for VTK libs (-lvtkRendering)])
AC_LINK_IFELSE(
    [AC_LANG_PROGRAM(
        [[
#include "vtkCubeSource.h"
#include "vtkCylinderSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkCamera.h"
        ]],
        [[
  //  Cube
  //
  vtkCubeSource * cube = vtkCubeSource::New();
  cube->SetCenter(2.0,0.0,0.0);
  vtkPolyDataMapper * cubeMapper = vtkPolyDataMapper::New();
  cubeMapper->SetInputConnection(cube->GetOutputPort());
  vtkActor * cubeActor = vtkActor::New();
  cubeActor->SetMapper(cubeMapper);
  cubeActor->GetProperty()->SetColor(0.5, 1.000, 0.5);
        ]])],
        AC_MSG_RESULT(yes),
        [ AC_MSG_RESULT(no);
          AC_MSG_ERROR([one or more missing VTK libraries!])])


-- 
Edward H. Hill III, PhD  |  ed at eh3.com  |  http://eh3.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070709/6ded8c37/attachment.pgp>


More information about the vtkusers mailing list