[vtkusers] building MATLAB MEX files with vtk 6.1?
Meehan, Bernard
MEEHANBT at nv.doe.gov
Wed Aug 6 16:58:59 EDT 2014
I'd much rather do this in cmake - I do have the "Mastering CMake" book
(haven't yet mastered it, or mex for that matter).
I think that the first problem I was having with the mex script was that
the libraries needed to be specified with the version numbers?
This seemed to get farther:
#!/bin/sh
MEX=/Applications/MATLAB_R2013b.app/bin/mex
$MEX -largeArrayDims \
-I/Users/meehanbt/VTK/include/vtk-6.1/ \
hello.cxx \
-L/Users/meehanbt/VTK/lib/ \
-lvtkCommonCore-6.1 \
-lvtkCommonDataModel-6.1 \
-lvtkRenderingCore-6.1 \
-lvtkRenderingOpenGL-6.1 \
-lvtkRenderingFreeTypeOpenGL-6.1 \
-lvtkInteractionStyle-6.1
Which gave this error:
Undefined symbols for architecture x86_64:
"vtkSphereSource::New()", referenced from:
_mexFunction in hello.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
mex: link of ' "hello.mexmaci64"' failed.
On 8/6/14 1:38 PM, "David Gobbi" <david.gobbi at gmail.com> wrote:
>Also, though this is slightly off-topic, I'd also like to point out that
>it is
>possible (and not very difficult) to build mex files with cmake without
>using mex at all. After all, "mex" is just a shell script that calls the
>compiler. Cmake can do that and a whole lot more.
>
> - David
>
>
>On Wed, Aug 6, 2014 at 2:27 PM, David E DeMarle
><dave.demarle at kitware.com> wrote:
>> You will also be interested in this branch, in which Jameson restored
>>VTK's
>> matlab interface, which was lost in 6.0.
>> * http://review.source.kitware.com/#/c/16043/
>>
>> On Wed, Aug 6, 2014 at 4:14 PM, David Gobbi <david.gobbi at gmail.com>
>>wrote:
>>>
>>> Hi Bernard,
>>>
>>> As you have rightly guessed, the libraries vtkCommon, vtkRendering,
>>> etc. no longer exist in VTK 6. The minimal set of libraries that you
>>> need for VTK 6 are probably the following:
>>>
>>> vtkCommonCore
>>> vtkCommonDataModel
>>> vtkRenderingCore
>>> vtkRenderingOpenGL
>>> vtkRenderingFreeTypeOpenGL
>>> vtkInteractionStyle
>>>
>>> - David
>>>
>>>
>>> On Wed, Aug 6, 2014 at 11:13 AM, Meehan, Bernard <MEEHANBT at nv.doe.gov>
>>> wrote:
>>> > I've tried to get a couple of tutorials built using CMake and haven't
>>> > had a
>>> > whole lot of luck ...
>>> >
>>> > http://www.cmake.org/Wiki/CMake/MatlabMex
>>> >
>>> >
>>>http://www.mathworks.com/matlabcentral/fileexchange/19638-visualization-
>>>toolkit--vtk--mex-interface
>>> >
>>>http://www.kitware.com/media/html/MATLABAndGNURIntegrationWithVTK.html
>>> >
>>> > 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:
>>> > #!/bin/sh
>>> > MEX=/Applications/MATLAB_R2013b.app/bin/mex
>>> > $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?
>_______________________________________________
>Powered by www.kitware.com
>
>Visit other Kitware open-source projects at
>http://www.kitware.com/opensource/opensource.html
>
>Please keep messages on-topic and check the VTK FAQ at:
>http://www.vtk.org/Wiki/VTK_FAQ
>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list