[vtkusers] VTK and MATLAB mex files

Amy Squillacote ahs at cfdrc.com
Thu Apr 17 12:43:12 EDT 2008


Please see my comments interspersed below.

Phil Goddard wrote:
> I'm wondering if anyone can give me some details regarding creating MATLAB
> mex files to interface with VTK.
> (I'm working on Windows XP and if possible, for various reasons, would
> prefer using MS Visual Studio.)
>
> I am a very experienced MATLAB programmer, and the MATLAB side of the
> equation isn't where I'm stuck.
> I am very new to VTK (I've only been looking at the app and the archive for
> this group for a few hours) and this is where I'm seeking assistance.
> And although there are various examples of mex files listed in the archive,
> all very useful, they don't address some very basic questions that I have:
>
> I believe that I need to compile the VTK source code down to shared
> libraries myself.
> Is cmake essential for this?
> If so, are there any examples of what the CMakeLists.txt file looks like?
>   

You are correct that CMake is used for creating makefiles, VS 
project/workspace files, etc. You do not need to write CMakeLists.txt 
files to build VTK. They have already been written and are in the VTK 
source tree.

> >From my understanding cmake is a utility for creating things like Visual
> Studio projects, or gcc make files, that will do the actual build (and hence
> isn't essential for the build step).
> Can anyone give an example of either generating a VS project, or send me a
> copy of a pre-generated project that I might look at and/or use?
> If I have the Project (or gcc make file) as my starting point do I still
> need cmake?
>
>   

You are correct that CMake is used for generating makefiles and 
project/workspace files. It is a configuration step prior to compiling 
the c++ code for VTK. Because of the number of different configuration 
options possible for VTK, you are better off running CMake yourself to 
generate your project/workspace files rather than getting them from 
someone else. This way, you can ensure that the project files that you 
are using are configured correctly for your system.

> I've looked at the example http://www.vtk.org/Wiki/VTK/VTKMatlab
> It indicates that within VTK a shared library has a dot.a extension.
> Why is that?  Why not a standard dot.lib extension?
>
>   

The person who wrote that wiki page was using the MinGW compiler, which 
produces library files with unix-style file extensions (i.e., .a / .so 
instead of .lib / .dll). If you build VTK with Visual Studio, you will 
get the file extensions you expect.

> If I try to make the mex file from the above example I get a compiler
> message about vtkConfigure.h not beng found.
> There is a vtkConfigure.h.in
> What is the dot.in extension for?
> If I (mindlessly) change this to a standard dot.h file (is that sensible?)
> then I get errors related to not knowing what to do with #cmakedefine.
> Which gets me back to wondering if cmake is essential.
>
>   

vtkConfigure.h will be in the top level of your VTK build tree; this 
file is configured for your system from vtkConfigure.h.in found in the 
VTK source tree, so just removing the .in extension in the source tree 
will not work.

- Amy

> Any tips for a beginner would be appreciated.
>
> Phil.
>
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>   

-- 
Amy Squillacote                    Phone: (256) 726-4839
Computer Scientist                 Fax: (256) 726-4806
CFD Research Corporation           Web: http://www.cfdrc.com
215 Wynn Drive, Suite 501
Huntsville, AL  35805





More information about the vtkusers mailing list