[vtkusers] building MATLAB MEX files with vtk 6.1?

Meehan, Bernard MEEHANBT at nv.doe.gov
Wed Aug 6 13:13:57 EDT 2014

I've tried to get a couple of tutorials built using CMake and haven't had a whole lot of luck ...


I figured that I might try to do it by hand so to speak - just to prove to myself that I could get it to work. I used this as a test file (does nothing on purpose):
#include "mex.h"

#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#define VTK_CREATE(type, name) \
  vtkSmartPointer<type> name = vtkSmartPointer<type>::New()

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
  mexPrintf("Hi there!\n");
  VTK_CREATE(vtkSphereSource, source);

And I tried to compile it with:
$MEX -I/Users/meehanbt/VTK/include/vtk-6.1/ hello.cxx -L/Users/meehanbt/VTK/lib/ -lvtkCommon -lvtkRendering

Obviously, for VTK 6.1 - the libraries are much more finely grained ... and I just did a copy/paste from a webpage somewhere. Trying to build the simple program gives:
ld: library not found for -lvtkCommon
clang: error: linker command failed with exit code 1 (use -v to see invocation)

    mex: link of ' "hello.mexmaci64"' failed.

Does anyone have any advice for how I would go about making a simple data display window or something like that as a MEX file?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140806/64024bd7/attachment.html>

More information about the vtkusers mailing list