Linking with Boost libraries fails

Right now I am trying to recompile ParaView 5.13 with the LAS reader option turned on, on Windows 11. I have downloaded a Boost library version 1.74 for vc142 and with mt, and I have compiled sources of liblas with the same tools and corresponding options. I already did the same thing with older versions successfully, but now I am stuck with some strange error message when linking \vtkIOLAS-pv5.13.dll - as follows:

LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc142-mt-x64-1_74.lib'

The failing command is

C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1442~1.344\bin\Hostx86\x64\link.exe /nologo VTK\IO\LAS\CMakeFiles\IOLAS.dir\vtkLASReader.cxx.obj /out:bin\vtkIOLAS-pv5.13.dll /implib:lib\vtkIOLAS-pv5.13.lib /pdb:bin\vtkIOLAS-pv5.13.pdb /dll /version:5.13 /machine:x64 /INCREMENTAL:NO lib\vtkFiltersGeneral-pv5.13.lib C:\dev\liblas\rel\install\lib\liblas_c.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_filesystem-vc142-mt-x64-1_74.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_iostreams-vc142-mt-x64-1_74.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_program_options-vc142-mt-x64-1_74.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_system-vc142-mt-x64-1_74.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_thread-vc142-mt-x64-1_74.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_serialization-vc142-mt-x64-1_74.lib lib\vtkFiltersCore-pv5.13.lib lib\vtkCommonExecutionModel-pv5.13.lib lib\vtkCommonDataModel-pv5.13.lib lib\vtkCommonMisc-pv5.13.lib lib\vtkCommonTransforms-pv5.13.lib lib\vtkCommonMath-pv5.13.lib lib\vtkkissfft-pv5.13.lib lib\vtkCommonCore-pv5.13.lib lib\vtktoken-pv5.13.lib lib\vtksys-pv5.13.lib ws2_32.lib dbghelp.lib psapi.lib C:\dev\liblas\rel\install\lib\liblas.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_iostreams-vc142-mt-x64-1_74.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_regex-vc142-mt-x64-1_74.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_program_options-vc142-mt-x64-1_74.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_thread-vc142-mt-x64-1_74.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_chrono-vc142-mt-x64-1_74.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_date_time-vc142-mt-x64-1_74.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_atomic-vc142-mt-x64-1_74.lib C:\local\boost_1_74_0\lib64-msvc-14.2\boost_serialization-vc142-mt-x64-1_74.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST:EMBED,ID=2

If I split this command line, simply replacing space chars with \n, this is how it looks like:

C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1442~1.344\bin\Hostx86\x64\link.exe
/nologo
VTK\IO\LAS\CMakeFiles\IOLAS.dir\vtkLASReader.cxx.obj
/out:bin\vtkIOLAS-pv5.13.dll
/implib:lib\vtkIOLAS-pv5.13.lib
/pdb:bin\vtkIOLAS-pv5.13.pdb
/dll
/version:5.13
/machine:x64
/INCREMENTAL:NO
lib\vtkFiltersGeneral-pv5.13.lib
C:\dev\liblas\rel\install\lib\liblas_c.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_filesystem-vc142-mt-x64-1_74.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_iostreams-vc142-mt-x64-1_74.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_program_options-vc142-mt-x64-1_74.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_system-vc142-mt-x64-1_74.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_thread-vc142-mt-x64-1_74.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_serialization-vc142-mt-x64-1_74.lib
lib\vtkFiltersCore-pv5.13.lib
lib\vtkCommonExecutionModel-pv5.13.lib
lib\vtkCommonDataModel-pv5.13.lib
lib\vtkCommonMisc-pv5.13.lib
lib\vtkCommonTransforms-pv5.13.lib
lib\vtkCommonMath-pv5.13.lib
lib\vtkkissfft-pv5.13.lib
lib\vtkCommonCore-pv5.13.lib
lib\vtktoken-pv5.13.lib
lib\vtksys-pv5.13.lib
ws2_32.lib
dbghelp.lib
psapi.lib
C:\dev\liblas\rel\install\lib\liblas.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_iostreams-vc142-mt-x64-1_74.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_regex-vc142-mt-x64-1_74.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_program_options-vc142-mt-x64-1_74.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_thread-vc142-mt-x64-1_74.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_chrono-vc142-mt-x64-1_74.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_date_time-vc142-mt-x64-1_74.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_atomic-vc142-mt-x64-1_74.lib
C:\local\boost_1_74_0\lib64-msvc-14.2\boost_serialization-vc142-mt-x64-1_74.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
/MANIFEST:EMBED,ID=2

So as can be seen, there is indeed a lib file with full path listed as follows - even twice: C:\local\boost_1_74_0\lib64-msvc-14.2\boost_thread-vc142-mt-x64-1_74.lib, but the little difference is the missing prefix lib...
Actually the binary installation of the boost library includes both variants, with and without the prefix. The CMake configuration finds the version without prefix, and generates the above link command accordingly, while for some reason one of the input files is asking for the variant wants to have the prefix!
Now I am somewhat lost!
Actually I can open vtkLASReader.cxx.obj with a hex editor and find the libboost_thread... filename (including the prefix) somewhere inside, so I assume that this object file is “asking” for it, so I would have to somehow “tell” the build process of that object file: “yes, you can get that boost_thread library, but only if you drop that stupid prefix”. But how can I achieve that?

TBH with complex dependencies such as boost and liblas, in maybe be simpler to use the superbuild.

Right - looks like this would be a solution. However, I rather like to solve the problems one by one: first get the ParaView program built, then add my own custom application (AthosGEO) on top of it and get it running, and only then jump into the stormy waters of getting a superbuild working. But well, if nothing else…

However, I found now a solution, by adding some more adaptations to the VTK/IO/LAS subdirectory CMakeLists.txt file that looks now as follows:

vtk_module_find_package(PRIVATE_IF_SHARED
  PACKAGE libLAS)

set(classes
  vtkLASReader)

vtk_module_add_module(VTK::IOLAS
  CLASSES ${classes})

## BCO 2024-11-01
## the following is changed from version 5.12, but still not properly working for current
## versions of liblas, so again we remove all version dependencies
## BCO 2025-01-06
## the Windows version did not link this way because it asked for a "libboost_threads...lib"
## library, while only a "boost_threads...lib" was offered (although also the lib... variant
## would have been available). It turned out that the reason was an "autolinking" feature that
## could be disabled by adding some pseudo "target" as shown below. Now the whole thing
## actually worked!
set(liblas_boost_dependencies)
vtk_module_find_package(PRIVATE_IF_SHARED
  PACKAGE Boost
  COMPONENTS program_options thread system iostreams filesystem serialization
  FORWARD_VERSION_REQ EXACT
  VERSION_VAR         "@Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@.@Boost_SUBMINOR_VERSION@")
list(APPEND liblas_boost_dependencies
  Boost::filesystem
  Boost::iostreams
  Boost::program_options
  Boost::system
  Boost::thread
  Boost::serialization
  Boost::disable_autolinking)

##set(liblas_boost_dependencies)
##if (libLAS_VERSION VERSION_LESS "1.8.2" OR
##    libLAS_VERSION STREQUAL "1.8.2b1")
##  if (libLAS_VERSION STREQUAL "1.8.2b1")
##    set(boost_components
##      iostreams program_options serialization thread)
##  else ()
##    set(boost_components
##      program_options thread system iostreams filesystem)
##  endif ()
##  vtk_module_find_package(PRIVATE_IF_SHARED
##    PACKAGE Boost
##    COMPONENTS ${boost_components}
##    FORWARD_VERSION_REQ EXACT
##    VERSION_VAR         "@Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@.@Boost_SUBMINOR_VERSION@")
##  foreach (boost_component IN LISTS boost_components)
##    list(APPEND liblas_boost_dependencies
##      "Boost::${boost_component}")
##  endforeach ()
##endif ()

vtk_module_link(VTK::IOLAS
  PRIVATE
    # XXX(liblas-1.8.2): Use these when the minimum version is 1.8.2+.
    # Currently, the imported target names vary based on the platform. In
    # addition, the include interface is not set up properly. See
    # https://github.com/libLAS/libLAS/pull/153.
    # las las_c
    ${libLAS_LIBRARIES}
    ${liblas_boost_dependencies})
vtk_module_include(VTK::IOLAS
  PRIVATE
    ${libLAS_INCLUDE_DIRS})
vtk_add_test_mangling(VTK::IOLAS)

As is documented in the comments, I already had to solve some struggles with a liblas library that I had compiled and somewhat adapted already during my first step: getting the entire thing working on Linux. Basically I dropped all version checking that was only blocking the process for me, without finding a way to get it satisfied. Now I am working on the port to Windows, running into this new problem.
But finally you are right: I should possibly have a look into what the superbuild downloads as it’s liblas project because maybe that is a variant that would work as well! However, again I would have to adapt it to my own needs, like working with double instead of float (which is too little for “real world” coordinates) and maybe some other details that I forgot right now.

1 Like