[vtkusers] Vtk programming on Mac OS X with Xcode

Mike Jackson imikejackson at gmail.com
Mon Jul 9 08:06:36 EDT 2007


You have to know how VTK was built? Was it built against Carbon or  
Cocoa? After you find that out then you can include the proper system  
frameworks in your Xcode project such as CoreFoundation.framework or  
Cocoa.framework or Carbon.framework. If you use the CMakeLists.txt  
that come with each example you can generate a fully working Xcode  
project by doing:

cmake [path/to/source] -G Xcode

This will generate the Xcode project. If you are just doing the  
example and just want to see it run then you can always just do:

cmake [path/to/source]   (This assumes an 'out of source' build)

Makefiles will be generated and then you can type 'make' and then run  
the resulting executable. CMake will take care of getting all the  
proper libraries and frameworks linked into your executable.

Here is what I did:

514:[mjackson at Thor:Cxx]$ mkdir Build
515:[mjackson at Thor:Cxx]$ cd Build
516:[mjackson at Thor:Build]$ cmake ../
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Check size of void*
-- Check size of void* - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/Shared/OpenSource/ 
VTK-5.0.3/Examples/Tutorial/Step1/Cxx/Build
517:[mjackson at Thor:Build]$ make
Scanning dependencies of target Cone
[100%] Building CXX object CMakeFiles/Cone.dir/Cone.o
Linking CXX executable Cone
[100%] Built target Cone
518:[mjackson at Thor:Build]$ ./Cone

The cone program goes pretty quick so watch out for it.

Lastly, if you are doing purely C++ VTK Code and NOT going to employ  
anything Mac OS X specific (Windowing/GUI) then you could use Eclipse  
+ CDT as your IDE. I have written a tutorial about using it with CMake.

http://www.cmake.org/Wiki/CMake:Eclipse

-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On Jul 8, 2007, at 11:14 PM, Jing LI wrote:

> Thanks for prompt replying.
>
> I just would like to run the vtk tutorial codes Cone.cxx on Mac  
> using Xcode.
>
>
> I started the Xcode, from File->New Project->C++ Tool, and entered  
> the name
> for the project as vtkcone1.
>
> Deleted the main.cxx from the vtkcone1 project, and added Cone.cxx  
> to the
> project, set the Header Search Paths to the VTK include path, and  
> built it.
> The build was succeeded. Then I ran it, it gave out the error message:
>
> "ZeroLink: unknown symbol '_ZN13vtkConeSource3NewEv'
>
> Vtkcone1 has exited due to signal 6 (GIGABRT)."
>
> I checked the ZeroLink flag, it is unchecked. I dragged the vtk*.a  
> from
> VTKBuild/bin to the Xcode project, and rerun it. It gave out the error
>
> "
> ZeroLink: unknown symbol '_CFConstantStringClassReference'
>
> Vtkcone1 has exited due to signal 6 (SIGABRT).
> "
>
> Any idea about it? How to fix it?
>
> I greatly appreciate your help.
>
>
> Jing
>
>
> -----Original Message-----
> From: Mike Jackson [mailto:imikejackson at gmail.com]
> Sent: Monday, 9 July 2007 1:11 p.m.
> To: Jing LI
> Cc: vtkusers at vtk.org
> Subject: Re: [vtkusers] Vtk programming on Mac OS X with Xcode
>
> How hard this will be depends on how much "Windows" specific C++ code
> you used. If you just stuck to generally accepted C++ and the VTK
> toolkit, just rerun cmake on your CMakeLists.txt file to generate
> Xcode projects and compile. If you did NOT use CMake for your
> projects then you will have a tougher time getting the Xcode projects
> setup.
>
> Apple hosts a mail list just for Xcode questions: http://
> lists.apple.com/xcode-users
>
>
> -- 
> Mike Jackson   Senior Research Engineer
> Innovative Management & Technology Services
>
>
> On Jul 8, 2007, at 7:50 PM, Jing LI wrote:
>
>>
>> I need to convert some VTK VS .Net 2005 solutions to XCode projects
>> on Mac.
>> I am not familiar with Mac and XCode. I searched the web, only
>> found the
>> tutorials on programming vtk using cocoa with XCode.
>>
>> I do not want to change the original VTK C++ codes much, just want
>> to do as
>> simple as possible to make the VTK C++ codes run on Mac.
>>
>> Does any one have such experience?
>>
>> Thanks in advance,
>>
>> Jing
>>
>>
>>
>> _______________________________________________
>> 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
>
>




More information about the vtkusers mailing list