FS#51611 - [vtk6] System prefers linking to vtk6 instead of vtk7 when both vtk6 and vtk are installed

Attached to Project: Community Packages
Opened by Jakub Klinkovský (lahwaacz) - Monday, 31 October 2016, 14:23 GMT
Last edited by Florian Pritz (bluewind) - Saturday, 11 August 2018, 16:17 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Florian Pritz (bluewind)
Anatol Pomozov (anatolik)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Suppose that both vtk6 and vtk packages are installed. Compiling the example from [1] as instructed links the resulting binary against vtk6, which is wrong since that is the legacy version and the 7.0 version is available.

[1] http://www.vtk.org/Wiki/VTK/Examples/Cxx/SimpleOperations/UniformRandomNumber

$ cd UniformRandomNumber/
$ cmake .
$ make
$ ldd UniformRandomNumber | grep vtk
libvtkDomainsChemistryOpenGL2.so.1 => /usr/lib/libvtkDomainsChemistryOpenGL2.so.1 (0x00007f5583a8d000)
libvtkFiltersGeneric.so.1 => /opt/vtk6/lib/libvtkFiltersGeneric.so.1 (0x00007f558313c000)
libvtkFiltersHyperTree.so.1 => /opt/vtk6/lib/libvtkFiltersHyperTree.so.1 (0x00007f5582f09000)
libvtkFiltersParallelFlowPaths.so.1 => /opt/vtk6/lib/libvtkFiltersParallelFlowPaths.so.1 (0x00007f5582cde000)
libvtkFiltersParallelGeometry.so.1 => /opt/vtk6/lib/libvtkFiltersParallelGeometry.so.1 (0x00007f5582aad000)
libvtkFiltersParallelImaging.so.1 => /opt/vtk6/lib/libvtkFiltersParallelImaging.so.1 (0x00007f5582898000)
libvtkFiltersParallelMPI.so.1 => /opt/vtk6/lib/libvtkFiltersParallelMPI.so.1 (0x00007f558266c000)
libvtkFiltersParallelStatistics.so.1 => /opt/vtk6/lib/libvtkFiltersParallelStatistics.so.1 (0x00007f5582443000)
libvtkFiltersProgrammable.so.1 => /opt/vtk6/lib/libvtkFiltersProgrammable.so.1 (0x00007f5582237000)
libvtkFiltersPython.so.1 => /opt/vtk6/lib/libvtkFiltersPython.so.1 (0x00007f5582030000)
...

The minimal reproducible example without cmake is this:

$ g++ UniformRandomNumber.cxx -o UniformRandomNumber -I /usr/include/vtk/ -l vtkCommonCore
$ ldd UniformRandomNumber | grep vtk
libvtkCommonCore.so.1 => /opt/vtk6/lib/libvtkCommonCore.so.1 (0x00007f6101c6c000)
libvtksys.so.1 => /opt/vtk6/lib/libvtksys.so.1 (0x00007f6100ddd000)

Since cmake is not the issue, I guess this is due to /etc/ld.so.conf.d/vtk6.conf (provided by vtk6)?
This task depends upon

Closed by  Florian Pritz (bluewind)
Saturday, 11 August 2018, 16:17 GMT
Reason for closing:  Deferred
Additional comments about closing:  vtk6 has been move to AUR a while ago
Comment by Florian Pritz (bluewind) - Wednesday, 01 February 2017, 12:01 GMT
I'm sorry I only get around to looking at this now.

It seems that I can't reproduce the problem with vtk and vtk6 installed on my system neither with cmake nor by manually compiling. Can you check if you still see the issue?

Also I believe that this should not affect the compiled program since the soname of the library is supposed to tell you if they are compatible or not. Can you check if your compiled binary also runs with vtk6 removed after compilation? In theory it should.

In any case /etc/ld.so.conf.d/vtk6.conf is likely the reason why you see this output in ldd, but I'm unsure why it doesn't happen for me too. Can you show me the output of this command for you?

> ldconfig -p | grep libvtksys.so.1
libvtksys.so.1 (libc6,x86-64) => /usr/lib/libvtksys.so.1
libvtksys.so.1 (libc6,x86-64) => /opt/vtk6/lib/libvtksys.so.1
Comment by Jakub Klinkovský (lahwaacz) - Wednesday, 01 February 2017, 13:15 GMT
I'm still having the same issues. If I compile the example above with cmake, its execution fails (apparently libvtkDomainsChemistryOpenGL2.so is not present in vtk6 so the vtk7 version is taken, which does not work with other vtk6 libs):

$ ./UniformRandomNumber
./UniformRandomNumber: symbol lookup error: /usr/lib/libvtkRenderingOpenGL2.so.1: undefined symbol: _ZN17vtkPolyDataMapper6UpdateEiP20vtkInformationVector

If I compile it manually with g++ and link only the necessary libs, it runs fine (even when I uninstall vtk6).

The ldconfig command gives me the entries in the other order, which might correspond to the installation order of the two packages and hence the order in which the entries entered the cache:

$ ldconfig -p | grep libvtksys.so.1
libvtksys.so.1 (libc6,x86-64) => /opt/vtk6/lib/libvtksys.so.1
libvtksys.so.1 (libc6,x86-64) => /usr/lib/libvtksys.so.1

In any case, relying on VTK to do soname bumps properly is a big assumption. Currently all the libs in both vtk and vtk6 have soname version 1, but my issues confirm that they are not compatible.
Comment by Jakub Klinkovský (lahwaacz) - Wednesday, 01 February 2017, 13:22 GMT
Besides runtime errors due to vtk7-only libs, I'm also getting bunch of linking errors when compiling code that uses symbols missing in the vtk6 libs:

/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/libvtkIOLegacy.so: undefined reference to `vtkMolecule::SetLattice(vtkVector3d const&, vtkVector3d const&, vtkVector3d const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/libvtkIOLegacy.so: undefined reference to `vtkMolecule::HasLattice()'
/opt/vtk6/lib/libvtkCommonDataModel.so.1: undefined reference to `vtkDataArrayTemplate<long long>::SetArray(long long*, long long, int, int)'
/opt/vtk6/lib/libvtkCommonDataModel.so.1: undefined reference to `vtkDataArrayTemplate<int>::ResizeAndExtend(long long)'
/opt/vtk6/lib/libvtkCommonDataModel.so.1: undefined reference to `vtkDataArrayTemplate<long long>::WritePointer(long long, long long)'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/libvtkIOLegacy.so: undefined reference to `vtkAlgorithm::UpdateExtent(int const*)'
/opt/vtk6/lib/libvtkCommonExecutionModel.so.1: undefined reference to `vtkInformation::Set(vtkInformationDoubleVectorKey*, double*, int)'
/opt/vtk6/lib/libvtkCommonDataModel.so.1: undefined reference to `vtkDataArrayTemplate<long long>::ResizeAndExtend(long long)'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/libvtkIOLegacy.so: undefined reference to `vtkAlgorithm::Update(int, vtkInformationVector*)'
/opt/vtk6/lib/libvtkCommonDataModel.so.1: undefined reference to `vtkDataArrayTemplate<long long>::LookupValue(long long)'
/opt/vtk6/lib/libvtkCommonDataModel.so.1: undefined reference to `vtkDataArrayTemplate<unsigned char>::ResizeAndExtend(long long)'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/libvtkIOLegacy.so: undefined reference to `vtkMolecule::GetLattice(vtkVector3d&, vtkVector3d&, vtkVector3d&, vtkVector3d&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/libvtkIOLegacy.so: undefined reference to `vtkAlgorithm::UpdateTimeStep(double, int, int, int, int const*)'
/opt/vtk6/lib/libvtkIOCore.so.1: undefined reference to `vtkObjectFactory::CreateInstance(char const*)'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/libvtkIOLegacy.so: undefined reference to `vtkAlgorithm::Update(vtkInformation*)'
/opt/vtk6/lib/libvtkCommonExecutionModel.so.1: undefined reference to `vtkInformation::Set(vtkInformationIntegerVectorKey*, int*, int)'
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../lib/libvtkIOLegacy.so: undefined reference to `vtkAlgorithm::UpdatePiece(int, int, int, int const*)'
collect2: error: ld returned 1 exit status
Comment by Florian Pritz (bluewind) - Wednesday, 01 February 2017, 14:00 GMT
Can you show me the output of this?

> grep '.*' /etc/ld.so.conf /etc/ld.so.conf.d/*
/etc/ld.so.conf:#
/etc/ld.so.conf:# /etc/ld.so.conf
/etc/ld.so.conf:#
/etc/ld.so.conf:
/etc/ld.so.conf:include /etc/ld.so.conf.d/*.conf
/etc/ld.so.conf:
/etc/ld.so.conf:# End of file
/etc/ld.so.conf.d/dovecot.conf:/usr/lib/dovecot
/etc/ld.so.conf.d/fakechroot.conf:/usr/lib/libfakeroot/fakechroot/
/etc/ld.so.conf.d/fakeroot.conf:/usr/lib/libfakeroot
/etc/ld.so.conf.d/ffmpeg0.10.conf:/usr/lib/
/etc/ld.so.conf.d/ffmpeg0.10.conf:/usr/lib/ffmpeg0.10/
/etc/ld.so.conf.d/ffmpeg2.8.conf:/usr/lib/
/etc/ld.so.conf.d/ffmpeg2.8.conf:/usr/lib/ffmpeg2.8/
/etc/ld.so.conf.d/lib32-glibc.conf:/usr/lib32
/etc/ld.so.conf.d/opencascade.conf:/opt/opencascade/lib
/etc/ld.so.conf.d/openmpi.conf:/usr/lib/openmpi
/etc/ld.so.conf.d/R.conf:/usr/lib/R/lib
/etc/ld.so.conf.d/R.conf:
/etc/ld.so.conf.d/vtk6.conf:/opt/vtk6/lib
Comment by Jakub Klinkovský (lahwaacz) - Wednesday, 01 February 2017, 14:02 GMT
Here:

$ grep '.*' /etc/ld.so.conf /etc/ld.so.conf.d/*
/etc/ld.so.conf:#
/etc/ld.so.conf:# /etc/ld.so.conf
/etc/ld.so.conf:#
/etc/ld.so.conf:
/etc/ld.so.conf:include /etc/ld.so.conf.d/*.conf
/etc/ld.so.conf:
/etc/ld.so.conf:# End of file
/etc/ld.so.conf.d/cuda.conf:/opt/cuda/lib64
/etc/ld.so.conf.d/cuda.conf:/opt/cuda/lib
/etc/ld.so.conf.d/cuda.conf:/opt/cuda/nvvm/lib64
/etc/ld.so.conf.d/cuda.conf:/opt/cuda/nvvm/lib
/etc/ld.so.conf.d/fakeroot.conf:/usr/lib/libfakeroot
/etc/ld.so.conf.d/opencascade.conf:/opt/opencascade/lib
/etc/ld.so.conf.d/openmpi.conf:/usr/lib/openmpi
/etc/ld.so.conf.d/vtk6.conf:/opt/vtk6/lib
Comment by Florian Pritz (bluewind) - Wednesday, 01 February 2017, 14:21 GMT
Thanks. Looks like the /usr/lib includes I have probably influence the order. I'd assume that without such files you'll get /usr/lib as a default, but the default is probably added only at the end.

I'm not sure what's the best solution here though. Given the files have the same names and are not compatible, whatever we do will result in problems. Since ld.so also uses this cache and libraries are loaded using the cache, I'd expect that if you add /usr/lib to the search path you'll also get crashes. That said I didn't get any reports about such crashes yet and opencascade (dependency of freecad) seems to work without issues and I'd guess that not everyone has /usr/lib before the vtk6 path.

ldconfig parses the files in alphabetic order, so you can put "/usr/lib" in /etc/ld.so.conf.d/vtk.conf and it should work after running `ldconfig` again. I added the vtk maintainer (Anatol) so we can discuss if adding this file to the package is a good idea or if we should do something else.
Comment by Jakub Klinkovský (lahwaacz) - Wednesday, 01 February 2017, 14:30 GMT
Even when I place "/usr/lib" in the ld.so.conf files (anywhere), the order stays the same for me...
Comment by Jakub Klinkovský (lahwaacz) - Wednesday, 01 February 2017, 14:54 GMT
Heh, the order of vtk.conf and vtk6.conf depends on the locale: with LANG=C vtk.conf is before vtk6.conf, but with LANG=en_GB.utf8 (my "normal" locale) it is the other way around.

So to correct myself, adding "/usr/lib" to a file that is always parsed before vtk6.conf (e.g. 00_default.conf) indeed helps.
Comment by Florian Pritz (bluewind) - Sunday, 18 June 2017, 14:09 GMT
Anatol, what's the status of this?

Loading...