[vtkusers] Re: vtkMy TCL packages in static build

Goodwin Lawlor goodwin.lawlor at ucd.ie
Thu Sep 23 15:15:10 EDT 2004


Hi Dean,

> thanks for the sample.  It seems that your project is modelled after
> VTK/Examples//Build/vtkLocal which contains all the user defined
> classes in that root directory and not with multiple sub-dirs as
> in VTK/Examples/Build/vtkMy

Nothing is ever easy :-(

> SET( VTK_EXTRA_TCL_LIBRARIES ${VTK_EXTRA_TCL_LIBRARIES}
>      vtkMyGraphicsTCL
>      vtkMyImagingTCL
>      vtkMyHybridTCL
>      vtkMyIoTCL
>      vtkMyRenderingTCL )

This looks to be right... my project uses the vtk output library path. If
yours has its own one then you'll have to add it with LINK_DIRECTORIES().
See below.

> but I do not know what to do about the extern C scripting that precedes.
>
> Does this seem sensible:
Pretty much. For some reason Vtkmygraphicstcl_Init etc. is always
capitalized (and there was a typo- the g in graphics was omitted).  You only
need the ${BSLASH} for the body on the #define.

 ////////////////////////////////////////////
 # Start of LocalUserOptions.cmake

 STRING(ASCII 92 BSLASH)
STRING(ASCII 34 QUOTE)

 SET( VTK_EXTRA_TCL_WRAPPING_CODE
      "#include ${QUOTE}vtkMyGraphicsInstantiator.h${QUOTE}
       #include ${QUOTE}vtkMyImagingInstantiator.h${QUOTE}
       #include ${QUOTE}vtkMyHybridInstantiator.h${QUOTE}
       #include ${QUOTE}vtkMyIoInstantiator.h${QUOTE}
       #include ${QUOTE}vtkMyRenderingInstantiator.h${QUOTE}
       extern ${QUOTE}C${QUOTE} int Vtkmygraphicstcl_Init(Tcl_Interp
*interp);
       extern ${QUOTE}C${QUOTE} int Vtkmyiotcl_Init(Tcl_Interp *interp);
       extern ${QUOTE}C${QUOTE} int Vtkmyhybridtcl_Init(Tcl_Interp *interp);
       extern ${QUOTE}C${QUOTE} int Vtkmyrenderingtcl_Init(Tcl_Interp
*interp);
      #define VTK_EXTRA_TCL_INIT ${BSLASH}
      if (Vtkmygraphicstcl_Init(interp) == TCL_ERROR) ${BSLASH}
          { ${BSLASH}
          return TCL_ERROR; ${BSLASH}
          } ${BSLASH}
      if (Vtkmyiotcl_Init(interp) == TCL_ERROR) ${BSLASH}
          { ${BSLASH}
          return TCL_ERROR; ${BSLASH}
          } ${BSLASH}
      if (Vtkmyhybridtcl_Init(interp) == TCL_ERROR) ${BSLASH}
          { ${BSLASH}
          return TCL_ERROR; ${BSLASH}
          } ${BSLASH}
      if (Vtkmyrenderingtcl_Init(interp) == TCL_ERROR) ${BSLASH}
          { ${BSLASH}
          return TCL_ERROR; ${BSLASH}
          } " )

 SET( VTK_EXTRA_TCL_LIBRARIES ${VTK_EXTRA_TCL_LIBRARIES}
      vtkMyGraphicsTCL
      vtkMyImagingTCL
      vtkMyHybridTCL
      vtkMyIoTCL
      vtkMyRenderingTCL )

INCLUDE_DIRECTORIES("Paths_to_instantiator_headers")
LINK_DIRECTORIES("Path_to_local_libs")

 # End of LocalUserOptions.cmake


> Also, do I create a LocalUserOptions.cmake and place it in my VTK source
> tree:
Yes- place it here though: VTK/Wrapping/Tcl/LocalUserOptions.cmake

When you run cmake for the vtk build, check in
VTK/Wrapping/Tcl/vtkTkAppInitConfigure.h to make sure everything looks OK.
This header gets included in vtkTkAppInit.cxx

> I'm not sure what you mean here...
See above cmake script. You can leave the instantiators out, if you like.

One thing to watch out for is that the vtk build may need two passes. Things
are slightly cyclic.
- Build vtk libs first... vtk.exe wont link because there's no local libs
- Build local libs, linking in vtk libs
- Rebuild vtk (ie link in local libs to create vtk.exe)

Alternatively to this approach is to build a new executable (say
"myvtk.exe") during your local build and link everything needed- this gets
around the cyclic thing. If you try this, build myvtk.exe as a windows app
(not a console app like vtk.exe). There are two benefits:
1. You can use "console show" and "console hide"... bind {console show} to
the "u" key instead of {wm deiconify .vtkInteract}
2. vtk tcl examples will pop up the render window only, ie, without the
console

hth

Goodwin






More information about the vtkusers mailing list