Vcpkg: vtk port: debug build is linked against release lzma.dll

Created on 21 Aug 2019  路  18Comments  路  Source: microsoft/vcpkg

After a "vcpkg install vtk", the debug build of vtkIOCore-8.2.dll has a dependency to lzma.dll instead of lzmad.dll. Now:

  • if I add lzmad.lib in the dependencies of a vcxproj for the debug configuration (as I should), lzma.dll is (rightly) not copied to the output directory and the produced exe (rightly) fails to run
  • if I add lzma.lib instead, it is (rightly) not found by the linker in debug mode.
port-bug

Most helpful comment

@cenit @trebahl These changes seem to have fixed it for me. Screenshot of fixed vtkIOCore-8.2.dll

Let me know how I should submit my PR.

https://github.com/manvscode/vcpkg/commit/7663d324b5a3f73f06ce3ad5e2f8fbcc0bce990f

All 18 comments

@trebahl Can you write the reproduction process more clearly?

I typed vcpkg install vtk on a freshly installed vcpkg. In the debug build, vtkIOCore-8.2.dll is linked against lzma.dll instead of lzmad.dll.

@trebahl Thanks for reporting this issue.
I cannot repro this issue now, please provide the c++ source file.
Thanks.

@shuitianxu assuming the problem exists (trusting @trebahl, not verified) there is no need for a cpp file to verify it. Just using a dependency walker should highlight the issue.
vtk is a huge beast, it is possible that the port requires some work... do you have time and willpower, @trebahl?

@cenit I am seeing this issue as well.
Screenshot

Ok so issue confirmed
@manvscode do you have time to investigate it (checking the vtk build scripts to see where is the problem)? That would ease the writing of a fix a lot!

@cenit I am new to vcpkg and cmake so I don't know how much help I can provide. Nevertheless, the problem appears to be in some cmake files that are generated in $VCPKG_ROOT/installed/x64-windows/share/vtk:

In Modules/vtklzma.cmake, I see:

set(vtklzma_LIBRARIES "optimized;${VTK_INSTALL_PREFIX}/lib/lzma.lib")

I would expect this to have been something like:

set(vtklzma_LIBRARIES "optimized;${VTK_INSTALL_PREFIX}/lib/lzma.lib;debug;${VTK_INSTALL_PREFIX}/debug/lib/lzmad.lib")

A similar problem appears in Modules/vtktiff.cmake with the same lzma dependency.

I don't know how these files are getting generated. Any suggestions?

Nope, it requires a careful inspection.
If you are new to cmake maybe it's too difficult for you, as of now, but it would still be a great way to master it quickly. Please share any progress you might do, I will share mine whenever I'll have time to work on it

Thanks for looking into it. I fear I'm too much of a n00b to vcpk and cmake to be of help, but I can perform whatever tests you require of me.

BTW, maybe a fix could be to give lzma lib the same name in debug and release. An added benefit would be to make it easier to refer to this lib from a vcproj, as you wouldn't have to enter a different list of dependencies in debug and release. I imagine this would require defining a vcpkg wide policy on this topic, though.

I think I might have a fix. I am testing it now.

@trebahl no, that's a very bad choice.
It almost destroys cmake if the name is the same, unfortunately. We have different names for lzma in debug/release for that reasons, and luckily LZMA also exposes a CMake Config, so the fix should be possible.

I don鈥檛 think it鈥檚 ok. You have to work with find_library(*_LIBRARY_DEBUG ...) and find_library(*_LIBRARY_RELEASE ...) and then exploit the select_library_configuration(*) to properly fill the *_LIBRARY symbol.
Replace * with the library name, LZMA in your case.

Otherwise, it鈥檚 possible that just removing the file (FindLZMA.cmake) might trigger the intervention of our own config file, which should provide proper symbols and targets

I'm basically following the pattern established by the fix-find-lz4.patch file. It looks like someone noticed a similar problem with lz4.

@cenit @trebahl These changes seem to have fixed it for me. Screenshot of fixed vtkIOCore-8.2.dll

Let me know how I should submit my PR.

https://github.com/manvscode/vcpkg/commit/7663d324b5a3f73f06ce3ad5e2f8fbcc0bce990f

Just open a PR :)

Works like a charm. Thanks a lot.

Was this page helpful?
0 / 5 - 0 ratings