# Undefined symbols vtkConvertSelection::ToSelectionType when building master on OSX, static lib

**URL:** https://discourse.vtk.org/t/undefined-symbols-vtkconvertselection-toselectiontype-when-building-master-on-osx-static-lib/1878
**Category:** Support
**Created:** [October 7, 2019, 1:10pm UTC](https://discourse.vtk.org/t/undefined-symbols-vtkconvertselection-toselectiontype-when-building-master-on-osx-static-lib/1878 "2019-10-07T13:10:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![simonesneault](https://discourse.vtk.org/user_avatar/discourse.vtk.org/simonesneault/32/67_2.png) [@simonesneault](https://discourse.vtk.org/u/simonesneault)
#### Post date: [October 7, 2019, 1:10pm UTC](https://discourse.vtk.org/t/undefined-symbols-vtkconvertselection-toselectiontype-when-building-master-on-osx-static-lib/1878/1 "2019-10-07T13:10:29Z")

</div>

Hello,

I’m having trouble building our app against VTK master on OSX,  
It fails with that error while linking :

```auto
Undefined symbols for architecture x86_64:
 "vtkConvertSelection::ToSelectionType(vtkSelection*, vtkDataObject*, int, vtkStringArray*, int, bool)", referenced from:
     vtkQtTreeModelAdapter::mimeData(QList<QModelIndex> const&) const in libvtkGUISupportQt-8.90.a(vtkQtTreeModelAdapter.o)
     vtkQtTableModelAdapter::mimeData(QList<QModelIndex> const&) const in libvtkGUISupportQt-8.90.a(vtkQtTableModelAdapter.o)
ld: symbol(s) not found for architecture x86_64

```

Am I missing a VTK library ? Or some module init ?  
VTK master, Qt 5.9.4, Xcode 10

Thanks

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [October 10, 2019, 7:13pm UTC](https://discourse.vtk.org/t/undefined-symbols-vtkconvertselection-toselectiontype-when-building-master-on-osx-static-lib/1878/2 "2019-10-10T19:13:01Z")

</div>

Do the Qt headers being used by the compilation match the libraries that are being linked against?

---

<div class="post-metadata">

### Author: ![simonesneault](https://discourse.vtk.org/user_avatar/discourse.vtk.org/simonesneault/32/67_2.png) [@simonesneault](https://discourse.vtk.org/u/simonesneault)
#### Post date: [November 4, 2019, 8:18am UTC](https://discourse.vtk.org/t/undefined-symbols-vtkconvertselection-toselectiontype-when-building-master-on-osx-static-lib/1878/3 "2019-11-04T08:18:50Z")

</div>

Hello @ben.boeckel  
Sorry for the late replay,

Yes the Qt headers are always those from Qt-5.9.4.  
We don’t use that part of the code, so I ended up patching VTK sources and remove the call to vtkConvertSelection::ToSelectionType that results in those undefined symbol.  
We must be doing something wrong somewhere but I couldn’t find some other solution.  
Thanks

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [November 4, 2019, 2:53pm UTC](https://discourse.vtk.org/t/undefined-symbols-vtkconvertselection-toselectiontype-when-building-master-on-osx-static-lib/1878/4 "2019-11-04T14:53:59Z")

</div>

I think you’d also need to remove the declaration from the class. But this seems odd anyways. Does `vtkConvertSelection` have a `ToSelectionType` implementation in its `.cxx` file?

---

<div class="post-metadata">

### Author: ![simonesneault](https://discourse.vtk.org/user_avatar/discourse.vtk.org/simonesneault/32/67_2.png) [@simonesneault](https://discourse.vtk.org/u/simonesneault)
#### Post date: [November 4, 2019, 3:09pm UTC](https://discourse.vtk.org/t/undefined-symbols-vtkconvertselection-toselectiontype-when-building-master-on-osx-static-lib/1878/5 "2019-11-04T15:09:30Z")

</div>

Yes, I can see the implementation of the method ToSelectionType in vtkConvertSelection.cxx  
Under OSX, we’re building VTK statically. Can this be the root of the pb ?

Here is the _pseudo_ patch applied

```auto
QMimeData *vtkQtTableModelAdapter::mimeData(const QModelIndexList &indexes) const
{
  // Only supports dragging single item right now ...

  if(indexes.size() == 0)
  {
    return nullptr;
  }
  /*
  vtkSmartPointer<vtkSelection> indexSelection = vtkSmartPointer<vtkSelection>::Take(QModelIndexListToVTKIndexSelection(indexes));
  //vtkSmartPointer<vtkSelection> pedigreeIdSelection = vtkSmartPointer<vtkSelection>::Take(vtkConvertSelection::ToSelectionType(indexSelection, this->Table, vtkSelectionNode::PEDIGREEIDS));

  // This is a memory-leak, we need to serialize its contents as a string, instead of serializing a pointer to the object
  vtkSelection* pedigreeIdSelection = vtkConvertSelection::ToSelectionType(indexSelection, this->Table, vtkSelectionNode::PEDIGREEIDS);

  if(pedigreeIdSelection->GetNode(0) == nullptr || pedigreeIdSelection->GetNode(0)->GetSelectionList()->GetNumberOfTuples() == 0)
  {
    return nullptr;
  }
  */
  std::ostringstream buffer;
  //buffer << pedigreeIdSelection;

  QMimeData *mime_data = new QMimeData();
  mime_data->setData("vtk/selection", buffer.str().c_str());

  return mime_data;
}

```

And here is the relevant part of our cmake superbuild script to build VTK

```auto
if( TH_BUILD_VTK )
	set( CURRENT VTK )
	set( CURRENT_VERSION 8.90.0 )
	message( STATUS "Adding ${CURRENT}-${CURRENT_VERSION}" )
	
	set( TH_VTK_BUILD_SHARED ON )
	set( TH_VTK_CMAKE_CUSTOM_CXX_FLAGS "${TH_CXX_FLAGS}" )
	if( APPLE )
		set( TH_VTK_BUILD_SHARED OFF )
		set( TH_VTK_CMAKE_CUSTOM_CXX_FLAGS "${TH_CXX_FLAGS} -std=c++11 -stdlib=libc++" )
	endif()
		
	if( WIN32 )
		set( TH_LZ4_LIBRARY ${INSTALL_ROOT}/LZ4-1.9.2/${TH_OS_NAME}/${CMAKE_CONFIGURATION_TYPES}/lib/lz4.lib )
	else()
		set( TH_LZ4_LIBRARY ${INSTALL_ROOT}/LZ4-1.9.2/${TH_OS_NAME}/${CMAKE_CONFIGURATION_TYPES}/lib/liblz4.a )
	endif()	

	ExternalProject_Add( ${CURRENT} DEPENDS LZ4

		GIT_REPOSITORY "git://vtk.org/VTK.git"
		GIT_TAG "81e2936740061a6887fc5ec9a6907b44277bfca1"
		TMP_DIR ${EXTERNAL_ROOT}/${CURRENT}/tmp
		STAMP_DIR ${EXTERNAL_ROOT}/${CURRENT}/tmp/stamp
		DOWNLOAD_DIR	${EXTERNAL_ROOT}/${CURRENT}/tmp/download
		SOURCE_DIR ${EXTERNAL_ROOT}/${CURRENT}/src
		BINARY_DIR ${EXTERNAL_ROOT}/${CURRENT}/build
		INSTALL_DIR ${INSTALL_ROOT}/${CURRENT}-${CURRENT_VERSION}/${TH_OS_NAME}

		PATCH_COMMAND ${CMAKE_COMMAND} -E copy_directory ${PATCH_DIR}/VTK-8.90.0 ${EXTERNAL_ROOT}/${CURRENT}/src

		CMAKE_ARGS

			-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
			-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}
			-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY=libc++
			-DCMAKE_CXX_FLAGS:STRING=${TH_VTK_CMAKE_CUSTOM_CXX_FLAGS}
			-DCMAKE_C_FLAGS:STRING=${TH_C_FLAGS}
			-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>/${CMAKE_CONFIGURATION_TYPES}
			-DBUILD_SHARED_LIBS:BOOL=${TH_VTK_BUILD_SHARED}

			# general
			-DVTK_BUILD_TESTING:STRING=OFF
			-DVTK_BUILD_QT_DESIGNER_PLUGIN:BOOL=OFF
			-DVTK_ENABLE_KITS:BOOL=ON
			-DVTK_LEGACY_SILENT:BOOL=ON
			-DVTK_REPORT_OPENGL_ERRORS_IN_RELEASE_BUILDS:BOOL=ON

			# wrapping
			-DVTK_WRAP_PYTHON:BOOL=OFF
			-DVTK_WRAP_JAVA:BOOL=OFF

			# groups
			-DVTK_GROUP_ENABLE_Qt:STRING=YES
			-DVTK_GROUP_ENABLE_Web:STRING=NO
			
			# modules
			-DVTK_MODULE_ENABLE_VTK_DomainsChemistry:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_DomainsChemistryOpenGL2:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_DomainsMicroscopy:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_DomainsParallelChemistry:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_FiltersOpenTURNS:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_FiltersParallel:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_GUISupportQtSQL:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_IOExodus:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_IOExportGL2PS:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_RenderingContext2D:STRING=YES
			-DVTK_MODULE_ENABLE_VTK_RenderingContextOpenGL2:STRING=YES
			-DVTK_MODULE_ENABLE_VTK_TestingCore:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_TestingGenericBridge:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_TestingIOSQL:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_TestingRendering:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_UtilitiesBenchmarks:STRING=NO			
			-DVTK_MODULE_ENABLE_VTK_ViewsContext2D:STRING=YES
			-DVTK_MODULE_ENABLE_VTK_WebCore:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_WrappingPythonCore:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_WrappingTools:STRING=NO
			
			# external libs
			-DVTK_MODULE_ENABLE_VTK_exodusII:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_gl2ps:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_hdf5:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_libharu:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_netcdf:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_netcfd:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_ogg:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_sqlite:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_theora:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_vpic:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_vtkDICOM:STRING=NO
			-DVTK_MODULE_ENABLE_VTK_vtkm:STRING=NO
			
			# build against our own LZ4
			-DVTK_MODULE_USE_EXTERNAL_VTK_lz4:BOOL=ON
			-DLZ4_INCLUDE_DIR:PATH=${INSTALL_ROOT}/LZ4-1.9.2/${TH_OS_NAME}/Release/include
			-DLZ4_LIBRARY:PATH=${TH_LZ4_LIBRARY}
	)
	# copy dll to the redist directory
	if( WIN32 )
		ExternalProject_Add_Step( ${CURRENT} redist_deploy DEPENDEES install
			COMMAND ${CMAKE_COMMAND} -E copy_directory ${INSTALL_ROOT}/${CURRENT}-${CURRENT_VERSION}/${TH_OS_NAME}/${CMAKE_CONFIGURATION_TYPES}/bin/ ${REDIST_ROOT}/${TH_OS_NAME}/${CMAKE_CONFIGURATION_TYPES}/
		)
	endif()
	
	# Cleanup debug include	
	if( ${TH_CONFIG_TYPE} STREQUAL Debug )
		ExternalProject_Add_Step( ${CURRENT} cleanup DEPENDEES install
			COMMAND ${CMAKE_COMMAND} -E remove_directory ${INSTALL_ROOT}/${CURRENT}-${CURRENT_VERSION}/${TH_OS_NAME}/${CMAKE_CONFIGURATION_TYPES}/include/	
			COMMAND ${CMAKE_COMMAND} -E remove_directory ${INSTALL_ROOT}/${CURRENT}-${CURRENT_VERSION}/${TH_OS_NAME}/${CMAKE_CONFIGURATION_TYPES}/share/
			COMMAND ${CMAKE_COMMAND} -E remove_directory ${INSTALL_ROOT}/${CURRENT}-${CURRENT_VERSION}/${TH_OS_NAME}/${CMAKE_CONFIGURATION_TYPES}/lib/cmake/
		)
	else()
		ExternalProject_Add_Step( ${CURRENT} cleanup DEPENDEES install	
			COMMAND ${CMAKE_COMMAND} -E remove_directory ${INSTALL_ROOT}/${CURRENT}-${CURRENT_VERSION}/${TH_OS_NAME}/${CMAKE_CONFIGURATION_TYPES}/share/
			COMMAND ${CMAKE_COMMAND} -E remove_directory ${INSTALL_ROOT}/${CURRENT}-${CURRENT_VERSION}/${TH_OS_NAME}/${CMAKE_CONFIGURATION_TYPES}/lib/cmake/
		)
	endif()
	
endif()

```

Maybe there is a conflict between some modules ?  
Thanks
