[vtkusers] Python wrapping example won't build on Mac OS X

Theodore D. Sternberg tdsternberg at lbl.gov
Mon Mar 15 14:47:14 EST 2004


On Mon, 15 Mar 2004, Theodore D. Sternberg wrote:
> 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

Clearly, the immediate problem here is that vtkLocalExamplePython.o
appears twice on the link line.  Maybe vtkLocalExamplePython.cxx is
somehow winding up twice in ${vtkLocalPYTHON_SRCS}?

If I remove (via cut & paste -- but I'd welcome a solution via the
CMakeLists file) one of those vtkLocalExamplePython.o's from the link 
line, it then complains about not finding a bunch of Python library 
functions -- _PyArg_ParseTuple and such.  So I added "-framework Python" 
to the link line.  That cut down the number of undefined symbols to a 
bunch that are supposed to come from VTK -- _PyArg_VTKParseTuple, 
_PyVTKClass_Check, ...





More information about the vtkusers mailing list