openslide / openslide-bin

Binary builds of OpenSlide and its dependencies
https://openslide.org/download/#binaries
GNU Lesser General Public License v2.1
19 stars 28 forks source link

Unable to locate libwebp during build process (winbuild) #243

Closed Buchi013 closed 7 months ago

Buchi013 commented 7 months ago

Environment: Ubuntu 22.04 WSL

I am trying to build Windows binaries of Openslide to read Tiff files compressed with WebP. libwebp and its .pc files are present on my system (/usr/local/), but are not found during the build process inside the provided winbuild docker image:

grafik

When building directly from source on the same system, without openslide-bin i get functioning (linux) binaries, able to handle WebP-TIFFs.

I suspected this might be due pkg-config searching different directories inside and outside the docker image:

Ubuntu: /usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig

Docker: /usr/lib64/pkgconfig:/usr/share/pkgconfig

However placing libwebp.pc in one of the two directories inside docker did not solve the issue.

Questions:

  1. How can I configure the winbuild tool within the Docker image to correctly locate libwebp during the build process?
  2. Is there a way to build the windows binaries (with libtiff including libwebp) directly from source on a Linux/WSL system?

Thanks in advance!

bgilbert commented 7 months ago

Builds performed by openslide-bin are completely self-contained: openslide-bin must know about all dependencies and must build them itself. You'll need to teach openslide-bin to build libwebp. Once you do this, you can build Windows binaries from either Linux or WSL as you'd like.

All of the dependencies must be built with Meson, including those that don't natively include Meson support. Fortunately, Meson's wrapdb already has a Meson port of libwebp.

The needed changes are:

  1. Add wrapdb's wrap file to subprojects by running meson wrap install libwebp.
  2. Add libwebp to _PROJECTS in software.py. You can test the update_url/update_regex by running ./bintool updates.
  3. Modify deps/meson.build to invoke the build, in the correct order relative to the other dependencies. Pass any necessary options as parameters, e.g. disabling building of command-line tools to reduce build time.

Note that newly-added dependencies sometimes have build bugs that need to be fixed in wrapdb or upstream, then patched in openslide-bin with a diff_files directive. Common problems include libraries a) not correctly filtering their exported symbols or b) taking a dependency on winpthreads when they don't actually use it. Either case will cause the build or smoke test to fail.

bgilbert commented 7 months ago

Out of curiosity, do you have a slide scanner that produces WebP TIFFs?

Buchi013 commented 7 months ago

Thank you very much for your help!

I followed your instructions (the library did indeed take a dependency on pthreads, which was fixable with a patch file as you described), and was able to create working Windows binaries capable of opening WebP-TIFFs.

I do not have a scanner that produces those files, but am currently experimenting with WebP-TIFFs (mainly converted from Aperio .svs/.tif files) for my bachelor thesis.

bgilbert commented 7 months ago

Cool, glad you got it working!