[vtkusers] Python wrapping example won't build on Mac OS X
Theodore D. Sternberg
tdsternberg at lbl.gov
Mon Mar 15 13:54:46 EST 2004
On Sat, 13 Mar 2004, Martin Costabel wrote:
> Theodore D. Sternberg wrote:
> > The VTK 4.4 source code ships with a small example (in
> > Examples/Build/vtkLocal) of how to add classes to VTK and get them wrapped
> > for use from Tcl and Python. It all builds and works wonderfully on
> > Linux, but on Mac OS X there are several problems:
>
> From looking at cvs logs, it seems to me that the vtkLocal example (and
> the other Examples) come from older archeological strata, below the
> great fix for Python on Mac OS X on 28 Aug 2003. The
> Examples/Build/vtkLocal/CMakeLists.txt just has the 2 lines
>
> ADD_LIBRARY(${PROJECT_NAME}Python MODULE ${vtkLocalPYTHON_SRCS})
> TARGET_LINK_LIBRARIES(${PROJECT_NAME}Python vtkCommonPython
> ${PROJECT_NAME})
>
> where more recent CMakeLists.txt files have a special treatment for
> APPLE. From Common/CMakeLists.txt:
>
> IF (APPLE)
> ADD_LIBRARY(vtk${KIT}PythonD ${KitPython_SRCS}
> ${Kit_PYTHON_EXTRA_SRCS})
> ADD_LIBRARY(vtk${KIT}Python MODULE vtk${KIT}PythonInit.cxx)
> TARGET_LINK_LIBRARIES(vtk${KIT}PythonD vtk${KIT} ${KIT_PYTHON_LIBS}
> ${PYTHON_LIBRARY})
> TARGET_LINK_LIBRARIES(vtk${KIT}Python vtk${KIT}PythonD)
> INSTALL_TARGETS(/lib/vtk vtk${KIT}PythonD)
> ELSE (APPLE)
> ADD_LIBRARY(vtk${KIT}Python MODULE ${KitPython_SRCS}
> ${Kit_PYTHON_EXTRA_SRCS})
> TARGET_LINK_LIBRARIES (vtk${KIT}Python vtk${KIT} ${KIT_PYTHON_LIBS})
> ENDIF(APPLE)
>
> Did you try to change the vtkLocal/CMakeLists.txt analogously?
Good idea ;-) Here's an attempt at doing that:
IF (VTK_WRAP_PYTHON)
VTK_WRAP_PYTHON2(${PROJECT_NAME}Python vtkLocalPYTHON_SRCS ${vtkLocal_SRCS})
IF (APPLE)
ADD_LIBRARY(${PROJECT_NAME}PythonD ${vtkLocalPYTHON_SRCS})
ADD_LIBRARY(${PROJECT_NAME}Python MODULE ${PROJECT_NAME}PythonInit.cxx)
TARGET_LINK_LIBRARIES(${PROJECT_NAME}PythonD ${PROJECT_NAME}
TARGET_LINK_LIBRARIES(${PROJECT_NAME}Python ${PROJECT_NAME}PythonD)
INSTALL_TARGETS(/lib/vtk ${PROJECT_NAME}PythonD)
ELSE (APPLE)
ADD_LIBRARY(${PROJECT_NAME}Python MODULE ${vtkLocalPYTHON_SRCS}
TARGET_LINK_LIBRARIES (${PROJECT_NAME}Python vtkLocalPython ${PROJECT_NAME})
ENDIF(APPLE)
INSTALL_TARGETS(/lib/vtk ${PROJECT_NAME}Python)
ENDIF (VTK_WRAP_PYTHON)
Now, something is still wrong. Maybe you can see what it is. When I try
building on Mac OS X it gets pretty far and finally fails with...
Building shared library
/Users/ted/vtk-wrap-example/build/bin/libvtkLocalPythonD.dylib...
/usr/local/bin/cmake -E remove -f /Users/ted/vtk-wrap-example/build/bin/libvtkLocalPythonD.dylib
c++ -dynamiclib -o /Users/ted/vtk-wrap-example/build/bin/libvtkLocalPythonD.dylib
vtkLocalExamplePython.o vtkLocalPythonInit.o vtkLocalExamplePython.o -L/Users/ted/usr/vtk/lib/vtk -L/Users/ted/vtk-wrap-example/build/bin
-lvtkLocal -lvtkCommon -framework AppKit -lpthread -lm
ld: multiple definitions of symbol _PyVTKClass_vtkLocalExampleNew
vtkLocalExamplePython.o definition of _PyVTKClass_vtkLocalExampleNew in section (__TEXT,__text)
vtkLocalExamplePython.o definition of _PyVTKClass_vtkLocalExampleNew in section (__TEXT,__text)
/usr/bin/libtool: internal link edit command failed
- Ted
More information about the vtkusers
mailing list