[vtkusers] vtk 5.6.1 on a mac wrapped in Java
David Gobbi
david.gobbi at gmail.com
Thu Dec 9 00:15:56 EST 2010
Hi Mark,
On the mac, libraries are looked for in the DYLD_LIBRARY_PATH as well as in
several default locations. When debugging library issues, it is usually
easiest to figure things out by running your program from the terminal and
manually setting DYLD_LIBRARY_PATH.
After starting the terminal, type:
export DYLD_LIBRARY_PATH=/your/library/directory/
Then run the program from the terminal. If you google "java" and
"DYLD_LIBRARY_PATH" you will probably come up with some useful java-specific
library info. Note that DYLD_LIBRARY_PATH is only meant to be a
quick-and-dirty way to get things to work, it isn't something you would use
when you are actually distributing an application.
The basic Windows paradigm of putting everything in the same directory
doesn't work on the Mac. Instead the mac uses "bundles" which are a
mac-specific directory structure, and the mac also uses something called the
"loader_path" which can be built-in to an executable to tell it where to
find its libraries.
David
On Wed, Dec 8, 2010 at 9:45 PM, Mark Roden <mmroden at gmail.com> wrote:
> I think I've made a bit more progress here.
>
> How are libraries supposed to be used on the mac?
>
> On windows, libraries are always looked for in the system PATH,
> starting with the local directory with the java file is run (at least,
> that's my understanding, and what appears to happen with this app on
> Windows).
>
> On the mac, where should these libraries sit? Do they have to be
> 'installed' (as in 'make; make install') in order for the java program
> to run? When I call System.loadlibrary("vtkgdcmJava"), will it look
> in the local path for the libraries? Because I'm trying to mimic the
> windows paradigm of putting all the libraries in the same place as the
> jar, but given the large number of links produced here, that might not
> be the right paradigm on the Mac or other unix flavors.
>
> Thanks,
> Mark
>
> On Wed, Dec 8, 2010 at 7:21 PM, Mark Roden <mmroden at gmail.com> wrote:
> > So, any idea on how to fix this issue? Getting
> >
> > ERROR: In
> /Users/mmroden/Documents/src/vtk-5.6.1/vtk-5.6.1/Filtering/vtkDemandDrivenPipeline.cxx,
> > line 802
> > vtkStreamingDemandDrivenPipeline (0x133f80aa0): Input for connection
> > index 0 on input port index 0 for algorithm
> > vtkImageChangeInformation(0x133f7fcc0) is NULL, but a vtkImageData is
> > required.
> >
> > right after trying to run a vtkChangeImageInformation pipeline.
> >
> > I tried this also using the straight vtk DICOM reader (rather than the
> > gdcm reader), and it gives the same error, but at a different point in
> > the app. Basically, anything that's pipeline-based appears to be
> > thinking that the inputs haven't been set, which is pretty much all of
> > the vtk stuff I have in there.
> >
> > Thanks for any help,
> > Mark
> >
> > On Thu, Dec 2, 2010 at 11:32 AM, Sebastien Jourdain
> > <sebastien.jourdain at kitware.com> wrote:
> >> the Unix makefile is fine.
> >> To setup release you just need to write Release in the CMake config
> >> for the build type (CMAKE_BUILD_TYPE).
> >> You can switch also the optimisation to -02 instead of -03 in the
> >> ..._FLAGS_RELEASE options.
> >>
> >> But I doubt that it could come from that.
> >>
> >> Seb
> >>
> >>
> >> On Thu, Dec 2, 2010 at 1:49 PM, Mark Roden <mmroden at gmail.com> wrote:
> >>> Maybe the problem is the build method I'm using for the libraries.
> >>>
> >>> I'm building both gdcm and vtk using Unix makefiles on the mac, since
> >>> the xcode stuff isn't working.
> >>>
> >>> How can I make sure that I'm building release versions on both
> >>> machines? There's a suggestion here:
> >>> http://comments.gmane.org/gmane.comp.lib.mitk.user/1052
> >>>
> >>> that this bug could be due to compilation problems.
> >>>
> >>> Specifically, I'd like for 64 bit release versions to be made. On
> >>> XCode, that's a dropdown selection, but typing 'make release' results
> >>> in 'don't know how to build release, stop', and I'm not sure what
> >>> 'make all' is doing.
> >>>
> >>> Thanks,
> >>> Mark
> >>>
> >>> On Thu, Dec 2, 2010 at 7:00 AM, Mark Roden <mmroden at gmail.com> wrote:
> >>>> The java code works fine on windows, it's the same code, shared via
> >>>> git on the different machines
> >>>>
> >>>> I'm not trying to inherit. vtkImageChangeInformation is exposed by
> >>>> the vtk java wrapping, but the vtlImageData I'm passing in isn't
> >>>> working.
> >>>>
> >>>> This code works in java on windows. It doesn't on mac. I use the
> >>>> same libraries underneath, or at least, the same versions of gdcm and
> >>>> vtk are built and used.
> >>>>
> >>>> On Thu, Dec 2, 2010 at 6:53 AM, Sebastien Jourdain
> >>>> <sebastien.jourdain at kitware.com> wrote:
> >>>>> I was talking about your Java code that was using VTK, not VTK
> itself.
> >>>>>
> >>>>> Moreover, I think that you can not inherit from VTK classes in
> Java...
> >>>>>
> >>>>> Seb
> >>>>>
> >>>>> On Thu, Dec 2, 2010 at 9:17 AM, Mark Roden <mmroden at gmail.com>
> wrote:
> >>>>>> Hi Sebastien,
> >>>>>>
> >>>>>> I can't use the windows binary on the mac-- the vtk underpinnings
> are
> >>>>>> still C++, which means that it's compiled into a dll on windows,
> which
> >>>>>> means (as far as I know, and as my experiments confirm), it doesn't
> >>>>>> work on a mac. I have to recompile vtk for the mac directly. The
> >>>>>> java wrappings (the jar) should be identical, though. Just to be
> >>>>>> safe, I'm using the mac-generated jars now.
> >>>>>>
> >>>>>> I am sure that the filenames have no spaces or special strings. If
> >>>>>> you look at the line
> >>>>>>
> >>>>>> String theString2 = sortedFT.get(i)
> >>>>>>
> >>>>>> I can stop there with the debugger and see the contents of the
> string,
> >>>>>> and it's clean.
> >>>>>>
> >>>>>> For what it's worth, Fred Fred asked about this error message a year
> >>>>>> ago, and he got no response:
> >>>>>>
> http://public.kitware.com/pipermail/vtkusers/2009-October/102935.html
> >>>>>> I don't know if he was in the same situation as me, though.
> >>>>>>
> >>>>>> Thanks,
> >>>>>> Mark
> >>>>>>
> >>>>>> On Thu, Dec 2, 2010 at 5:02 AM, Sebastien Jourdain
> >>>>>> <sebastien.jourdain at kitware.com> wrote:
> >>>>>>> Hi Mark,
> >>>>>>>
> >>>>>>> did you try your windows (Java) binary on your mac to see if you
> get
> >>>>>>> the same behavior ?
> >>>>>>> Are you sure that on your mac, the filename provided to the reader
> are
> >>>>>>> correct ? (no space or special string ?)
> >>>>>>>
> >>>>>>> Seb
> >>>>>>>
> >>>>>>> On Thu, Dec 2, 2010 at 12:01 AM, Mark Roden <mmroden at gmail.com>
> wrote:
> >>>>>>>> Hi all,
> >>>>>>>>
> >>>>>>>> So I managed to get vtk 5.6.1 to work on a mac with java wrappings
> on
> >>>>>>>> (10.6.5) and with gdcm.
> >>>>>>>>
> >>>>>>>> The following code is producing errors that I don't see on
> windows:
> >>>>>>>>
> >>>>>>>> IPPSorter sorter = new IPPSorter();
> >>>>>>>> sorter.SetComputeZSpacing(true);
> >>>>>>>> sorter.SetZSpacingTolerance(0.000001);
> >>>>>>>> Boolean sorted = sorter.Sort(theSeriesFiles);
> >>>>>>>> //sorter.Sort(ft);
> >>>>>>>>
> >>>>>>>> //have to make a vtk string array
> >>>>>>>> FilenamesType sortedFT = sorter.GetFilenames();
> >>>>>>>> long theSize = sortedFT.size();
> >>>>>>>> vtkStringArray sa = new vtkStringArray();
> >>>>>>>> for (int j = 0; j < theSize; j++) {
> >>>>>>>> String theString2 = sortedFT.get(j);
> >>>>>>>> sa.InsertNextValue(sortedFT.get(j));
> >>>>>>>> }
> >>>>>>>> gdcmReader.SetFileNames(sa);
> >>>>>>>>
> >>>>>>>> gdcmReader.Update();
> >>>>>>>>
> >>>>>>>> imageData = gdcmReader.GetOutput();
> >>>>>>>>
> >>>>>>>> //make sure that we're getting spacing and
> orientation info
> >>>>>>>> double[] spacing = imageData.GetSpacing();
> >>>>>>>> spacing[2] = sorter.GetZSpacing();
> >>>>>>>> imageData.SetSpacing(spacing);
> >>>>>>>> double[] origin = imageData.GetOrigin();
> >>>>>>>> double[] bounds = imageData.GetBounds();
> >>>>>>>> double[] extraOrigin = {0,0,0};//because vtk will
> only
> >>>>>>>> flip about 0,0,0
> >>>>>>>>
> >>>>>>>> vtkImageChangeInformation imageSpacingChange = new
> >>>>>>>> vtkImageChangeInformation();
> >>>>>>>> imageSpacingChange.SetInput(imageData);
> >>>>>>>> imageSpacingChange.SetOutputSpacing(spacing[0],
> >>>>>>>> spacing[1], spacing[2]);
> >>>>>>>> imageSpacingChange.SetOutputOrigin(extraOrigin);
> >>>>>>>> imageSpacingChange.Update();
> >>>>>>>>
> >>>>>>>> Once the last line is hit, the following error is reported in
> netbeans:
> >>>>>>>>
> >>>>>>>> ERROR: In
> /Users/mmroden/Documents/src/vtk-5.6.1/VTK-5.6.1/Filtering/vtkDemandDrivenPipeline.cxx,
> >>>>>>>> line 802
> >>>>>>>> vtkStreamingDemandDrivenPipeline (0x135884c10): Input for
> connection
> >>>>>>>> index 0 on input port index 0 for algorithm
> >>>>>>>> vtkImageChangeInformation(0x1358853c0) is NULL, but a vtkImageData
> is
> >>>>>>>> required.
> >>>>>>>>
> >>>>>>>> This code works perfectly well in Windows, and the spacing,
> origin,
> >>>>>>>> and bounds arrays all match the values in windows when loading the
> >>>>>>>> same series there. So, I know that the gdcm side of things is
> >>>>>>>> working, at least to the point that those arrays are being
> reported
> >>>>>>>> correctly.
> >>>>>>>>
> >>>>>>>> Because the pipeline is breaking there, nothing else is working.
> What
> >>>>>>>> can I do to fix it?
> >>>>>>>>
> >>>>>>>> Thanks,
> >>>>>>>> Mark
> >>>>>>>> _______________________________________________
> >>>>>>>> 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://www.vtk.org/mailman/listinfo/vtkusers
> >>>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>>
> >>
> >
> _______________________________________________
> 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://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101208/321e3cc7/attachment.htm>
More information about the vtkusers
mailing list