On Windows 10 using CMake 3.16.0 with Visual Studio 17, I get the following link error when building against vtk:x64-windows-static:
LINK : fatal error LNK1104: cannot open file 'pugixml.lib'
A sample CMakeLists file is attached. The source file contains an empty main method.
Confirmed.
After changing LINK_PRIVATE to LINK_PUBLIC in _SOURCE/IO/CityGML/CMakeLists.txt_ line 7, it works.
Hi @dbonhaus, thanks for reporting this issue!
I've fixed it in #9958, please update vcpkg and rebuild vtk.
Thanks.
Somehow I am still getting the same error. I updated my local copy of vcpkg, made sure that the relevant change was there, then reinstalled VTK (vtk:x64-windows-static) from scratch. I then deleted the cache for my sample project and reconfigured and rebuilt it, but I'm still getting the pugixml link error.
@dbonhaus Could you provide failure log?
The error message is not very informative:
"LINK : fatal error LNK1104: cannot open file 'pugixml.lib'"
The problem seems to be that pugixml.lib is in the project properties, but without an absolute path. I uploaded a snapshot of the linker properties in Visual Studio. Let me know if there is another log file that might be more informative and I will provide it.

@dbonhaus
Did you create this project yourself? vcpkg will add _VCPKG_PATH/installed/TRIPLET/lib_ / _VCPKG_PATH/installed/TRIPLET/debug/lib_ to the path LIB_PATH and try to link all static libraries in this path, so pugixml.lib should not be added by vcpkg.
No, the project was generated by CMake (3.16.0).
Confimed.
In VTKTargets.cmake:
set_target_properties(vtkIOCityGML PROPERTIES
INTERFACE_COMPILE_FEATURES "cxx_nullptr;cxx_override"
INTERFACE_LINK_LIBRARIES "vtkCommonCore;vtkCommonExecutionModel;vtkFiltersGeneral;vtkFiltersModeling;\$<LINK_ONLY:vtkCommonDataModel>;\$<LINK_ONLY:vtksys>;pugixml"
)
@JackBoosY I am having the same issue after updating vcpkg packages (one of which was vtk).
In _IO\CityGML\CMakeLists.txt_:
if(VTK_USE_SYSTEM_PUGIXML AND NOT pugixml_INCLUDE_DIRS)
find_package(pugixml REQUIRED)
vtk_module_link_libraries(vtkIOCityGML LINK_PUBLIC pugixml)
endif()
I think this is caused by the incorrect use of pugixml.
@dbonhaus @manvscode
Could you add find_dependency(pugixml CONFIG) to _VCPKG_PATH/installed/TRIPLET/share/VTK/VTKConfig.cmake_ line 110?
If it works, I will open a PR to fix it.
Hello @JackBoosY.
I having the same issue @manvscode described.
Adding find_dependency(pugixml CONFIG) doesn't seem to work.

@RamadanAhmed Sorry, we should include CMakeFindDependencyMacro.cmake first:
include(CMakeFindDependencyMacro)
find_dependency(pugixml CONFIG)
@JackBoosY after applying suggested changes I see the same issue with the pugixml.lib unfortunately.
The thing which is a bit confusing to me is that debug build should actually use the pugixml_d.lib but it is looking for pugixml.lib instead. Maybe this can give you a hint.
Just ran into the same problem.
What solved it temporarily for me is adding these two lines at the end of the installed VTKConfig.cmake
include(CMakeFindDependencyMacro)
find_dependency(pugixml REQUIRED)
Look forward to the proper fix.
@dbonhaus @manvscode
Could you addfind_dependency(pugixml CONFIG)to _VCPKG_PATH/installed/TRIPLET/share/VTK/VTKConfig.cmake_ line 110?If it works, I will open a PR to fix it.
I no longer see link errors involving pugixml, but I see two new ones:
1>vtkIOCore-8.2.lib(vtkLZMADataCompressor.cxx.obj) : error LNK2019: unresolved external symbol __imp_lzma_easy_buffer_encode referenced in function "protected: virtual unsigned __int64 __cdecl vtkLZMADataCompressor::CompressBuffer(unsigned char const *,unsigned __int64,unsigned char *,unsigned __int64)" (?CompressBuffer@vtkLZMADataCompressor@@MEAA_KPEBE_KPEAE1@Z)
1>vtkIOCore-8.2.lib(vtkLZMADataCompressor.cxx.obj) : error LNK2019: unresolved external symbol __imp_lzma_stream_buffer_decode referenced in function "protected: virtual unsigned __int64 __cdecl vtkLZMADataCompressor::UncompressBuffer(unsigned char const *,unsigned __int64,unsigned char *,unsigned __int64)" (?UncompressBuffer@vtkLZMADataCompressor@@MEAA_KPEBE_KPEAE1@Z)
I have the 2020.01 tag of vcpkg checked out.
@JackBoosY @RamanKutseika @dbonhaus I can confirm that adding these lines to VTKConfig.cmake, at line 110, will fix the problem:
include(CMakeFindDependencyMacro)
find_dependency(pugixml REQUIRED)
I tested both linking debug and release binaries. I do not see any problems with liblzma.
@RamanKutseika Port pugixml generated debug library named pugixml.lib, so I guess no fault here.
@dbonhaus
lzma library should be imported with path _${VTK_INSTALL_PREFIX}/lib/lzma.lib_ and _${VTK_INSTALL_PREFIX}/debug/lib/lzmad.lib_, you can find them in _share\vtk\Modules\vtklzma.cmake_
And VTK_INSTALL_PREFIX was set in VTKConfig,cmake line 13:
if (_vtk_installed_prefix_full STREQUAL _vtk_requested_prefix_full)
set(VTK_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../..")
else ()
set(VTK_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}")
get_filename_component(VTK_INSTALL_PREFIX "${VTK_INSTALL_PREFIX}" PATH)
get_filename_component(VTK_INSTALL_PREFIX "${VTK_INSTALL_PREFIX}" PATH)
endif ()
Hi guys, I've fixed this issue in #10379, please update vcpkg and rebuild vtk.
Thanks.
@dbonhaus
lzma library should be imported with path _${VTK_INSTALL_PREFIX}/lib/lzma.lib_ and _${VTK_INSTALL_PREFIX}/debug/lib/lzmad.lib_, you can find them in _share\vtk\Modules\vtklzma.cmake_And
VTK_INSTALL_PREFIXwas set inVTKConfig,cmakeline 13:if (_vtk_installed_prefix_full STREQUAL _vtk_requested_prefix_full) set(VTK_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../..") else () set(VTK_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}") get_filename_component(VTK_INSTALL_PREFIX "${VTK_INSTALL_PREFIX}" PATH) get_filename_component(VTK_INSTALL_PREFIX "${VTK_INSTALL_PREFIX}" PATH) endif ()
I just tried the latest vcpkg and I'm still seeing problems with lzma (but not with pugixml). I'm not sure I follow your comment. Are you saying I should explicitly specify lzma as a dependency in my CMake file? Shouldn't VTK take care of the dependency? Everything seems to be as you indicated in the VTK config files.
@dbonhaus
According to my comment above, lzma was imported through VTK_INSTALL_PREFIX to determine the absolute path of the dependent library, and the value of VTK_INSTALL_PREFIX is _VCPKG_PATH/installed/TRIPLET/share/vtk/../.._, then lzma library path should be _VCPKG_PATH/installed/TRIPLET/share/vtk/../../lib/lzma.lib_ and _VCPKG_PATH/installed/TRIPLET/share/vtk/../../debug/lib/lzmad.lib_. So we don't need to find lzma through find_package / find_dependency again.
So I think there should be no problem here.
Could you provide the failure log?
Here are the link errors:
1>vtkIOCore-8.2.lib(vtkLZMADataCompressor.cxx.obj) : error LNK2019: unresolved external symbol __imp_lzma_easy_buffer_encode referenced in function "protected: virtual unsigned __int64 __cdecl vtkLZMADataCompressor::CompressBuffer(unsigned char const *,unsigned __int64,unsigned char *,unsigned __int64)" (?CompressBuffer@vtkLZMADataCompressor@@MEAA_KPEBE_KPEAE1@Z)
1>vtkIOCore-8.2.lib(vtkLZMADataCompressor.cxx.obj) : error LNK2019: unresolved external symbol __imp_lzma_stream_buffer_decode referenced in function "protected: virtual unsigned __int64 __cdecl vtkLZMADataCompressor::UncompressBuffer(unsigned char const *,unsigned __int64,unsigned char *,unsigned __int64)" (?UncompressBuffer@vtkLZMADataCompressor@@MEAA_KPEBE_KPEAE1@Z)
@dbonhaus Could you provide the full log?
Thanks.
I modified the test project to reproduce the error.
vtk_test.zip
I also included the CMake cache file. I suspect something about the CMake configuration either is the problem or triggers the problem.
There seem to be a lot more problems with the test project associated with the use of the static run time (x64-windows-static). I added /MT to the CXX flags but it didn't help.
Well, now I can confirm that this issue still exists and I will continue to deal with this issue.
__imp_lzma_easy_buffer_encode incorrect EXPORT macro, I will fix this issue in the nearly futhre.
@Neumann-A Seems the export cmake files has problem, what do you think?
@JackBoosY: Is ParaView not built in x64-windows-static CI? I would have thought that this would have found such an issue in VTK (or LZMA).
@JackBoosY I checked the logs of #12342 and Paraview built fine with it. Maybe the problem is linking against VTK_LIBRARIES instead of a target? I currently don't have a installation of VTK so I cannot check the value of VTK_LIBRARIES.
@Neumann-A ParaView is not added to the pre-build process currently, and this issue appeared before adding ParaView.
@dbonhaus Does this issue still exist? Please note to use find_package(vtk CONFIG REQUIRED) instead of find_package(VTK CONFIG REQUIRED).
I've the same issue with vcpkg using wide integration.
@GeneralAdmin More details please?
I no longer see any link errors as of vcpkg 2020.11 if I use find_package(VTK CONFIG REQUIRED). It doesn't work with lower case vtk. If I specify components in the find_package command, I see the link error again, but that seems like a VTK issue rather than a vcpkg issue.
@dbonhaus thanks for the information.
Hi @martinken, can you please take a look?
We are not sure this issue is caused by vtk itself or vcpkg.
In the _share_ folder:
Directory of F:\vcpkg\installed\x64-windows-static\share\vtk
11/13/2020 12:15 AM <DIR> .
11/13/2020 12:15 AM <DIR> ..
06/24/2020 08:25 AM 1,761 copyright
11/13/2020 12:02 AM 1,063 Finddouble-conversion.cmake
11/13/2020 12:02 AM 1,396 FindEigen3.cmake
11/13/2020 12:02 AM 4,029 FindEXPAT.cmake
11/13/2020 12:02 AM 6,470 FindFFMPEG.cmake
11/13/2020 12:02 AM 1,739 FindFontConfig.cmake
11/13/2020 12:02 AM 7,447 FindFreetype.cmake
11/13/2020 12:02 AM 1,490 FindGL2PS.cmake
11/13/2020 12:02 AM 905 FindGLEW.cmake
11/13/2020 12:02 AM 1,905 FindJOGL.cmake
11/13/2020 12:02 AM 1,874 FindJsonCpp.cmake
11/13/2020 12:02 AM 3,697 FindLibHaru.cmake
11/13/2020 12:02 AM 2,901 FindLibPROJ.cmake
11/13/2020 12:02 AM 4,104 FindLibXml2.cmake
11/13/2020 12:02 AM 136 FindLZ4.cmake
11/13/2020 12:02 AM 3,208 FindLZMA.cmake
11/13/2020 12:02 AM 1,226 Findmpi4py.cmake
11/13/2020 12:02 AM 3,815 FindMySQL.cmake
11/13/2020 12:02 AM 3,654 FindNetCDF.cmake
11/13/2020 12:02 AM 2,162 FindODBC.cmake
11/13/2020 12:02 AM 688 FindOGG.cmake
11/13/2020 12:02 AM 23,053 FindOpenMP.cmake
11/13/2020 12:02 AM 1,298 FindOpenSlide.cmake
11/13/2020 12:02 AM 1,659 FindOpenVR.cmake
11/13/2020 12:02 AM 2,223 FindOSMesa.cmake
11/13/2020 12:02 AM 2,125 FindPEGTL.cmake
11/13/2020 12:02 AM 15,952 FindTBB.cmake
11/13/2020 12:02 AM 2,078 FindTHEORA.cmake
11/13/2020 12:02 AM 578 Findutf8cpp.cmake
11/13/2020 12:15 AM <DIR> patches
11/12/2020 10:53 PM 2,916 vcpkg_abi_info.txt
11/13/2020 12:02 AM 1,419 vtk-config-version.cmake
11/13/2020 12:02 AM 14,448 vtk-config.cmake
11/13/2020 12:02 AM 244 vtk-prefix.cmake
11/13/2020 12:02 AM 58,291 VTK-targets-debug.cmake
11/13/2020 12:02 AM 57,693 VTK-targets-release.cmake
11/13/2020 12:02 AM 59,557 VTK-targets.cmake
11/13/2020 12:02 AM 18 vtk-use-file-compat.cmake
11/13/2020 12:02 AM 84 vtk-use-file-deprecated.cmake
11/13/2020 12:02 AM 181 vtk-use-file-error.cmake
11/13/2020 12:02 AM 53,008 VTK-vtk-module-find-packages.cmake
11/13/2020 12:02 AM 298,605 VTK-vtk-module-properties.cmake
11/13/2020 12:02 AM 525 vtkCMakeBackports.cmake
11/13/2020 12:02 AM 4,687 vtkDetectLibraryType.cmake
11/13/2020 12:02 AM 7,469 vtkEncodeString.cmake
11/13/2020 12:02 AM 3,218 vtkHashSource.cmake
11/13/2020 12:02 AM 191,813 vtkModule.cmake
11/13/2020 12:02 AM 13,259 vtkModuleGraphviz.cmake
11/13/2020 12:02 AM 7,093 vtkModuleJson.cmake
11/13/2020 12:02 AM 21,956 vtkModuleTesting.cmake
11/13/2020 12:02 AM 14,383 vtkModuleWrapJava.cmake
11/13/2020 12:02 AM 44,651 vtkModuleWrapPython.cmake
11/13/2020 12:02 AM 6,669 vtkObjectFactory.cmake
06/24/2020 08:25 AM 1,958 vtkObjectFactory.cxx.in
06/24/2020 08:25 AM 1,680 vtkObjectFactory.h.in
11/13/2020 12:02 AM 289 vtkTestingDriver.cmake
11/13/2020 12:02 AM 2,880 vtkTestingRenderingDriver.cmake
11/13/2020 12:02 AM 5,621 vtkTopologicalSort.cmake
57 File(s) 979,251 bytes
3 Dir(s) 814,283,091,968 bytes free
I found that some cmake files start with uppercase VTK, and the rest start with lowercase vtk. I think there is something wrong here.
I found that some cmake files start with uppercase VTK, and the rest start with lowercase vtk. I think there is something wrong here.
no it is not.....
vtk-config.cmake is the important one
due to its naming the config can be found via find_package(VTK) AND find_packakge(vtk) but this doesn't mean both are correct. Internally VTKs config is probably using PACKAGE_FIND_NAME somewhere which is why lowercase vtk is not working. That said the correct way to find VTK is to always use uppercase VTK since that is used in any example by vtk itself (https://gitlab.kitware.com/vtk/vtk/-/blob/master/Examples/GUI/Qt/ImageViewer/CMakeLists.txt).
So this issue can be closed since find_package(VTK) is working