How to build for Windows as static libraries? #1182
-
The main .md file for libheif recommends using vcpkg to install and build libheif for Windows. The issue for me is that this produces dlls that need to be distributed with my application. I would much rather generate static libraries that are directly linked into the application, thus letting me keep it down to a single executable. Since I have zero - none - nada experience with cmake, I don't even know where to begin. It appears that files with the name CMakeLists.txt are the cmake equivalent of Makefiles, but I have no idea which of these I need to change, what modifications I need to make to them, and how to execute cmake to build when I'm finished. Looking for someone to walk me through the process of building libheif, libde265 and x265 as static link .LIB files. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Note that static linking is not allowed by the LGPL license. And by the way: x265 is GPL. You may only use that in your software if you also release the source code of your software. |
Beta Was this translation helpful? Give feedback.
-
libheif is going to be a bit of a slog to cut your teeth on, but since you have to start with libde265 anyway, it won't be too bad. The basic cmake gui is functional enough, point it to the base folder and then pick a build folder anywhere you want, hit configure, pick your build environment. You can choose options there, all you want is to uncheck BUILD_SHARED_LIBS, generate, open project or go find the project files in your build folder, and build. So opening libheif and changing to a new build folder for that (the UI is clunky about changing projects), configure. Uncheck the same BUILD_SHARED_LIBS, and skip down to LIBDE265_INCLUDE_DIR and LIBDE265_LIBRARY, fill them in appropriately. Uncheck everything in the list of plugins except WITH_LIBDE265. Maybe uncheck ENABLE_PLUGIN_LOADING. Now generate. That should get you a set of project files that will build you a minimally functional set of self-contained libheif executables. Rinse and repeat for JPEG/PNG/OpenJPG libraries if you want to be able to output into a useful format. BUILD_TESTING will generate a LOT of project files, that might be one you want to disable as well. Once you get the hang of it, you can do it all via commandline like a regular makefile process. The gui has Tools->Show My Changes that will give you the full commandline. But that's a tall order when you're not sure how cmake works at all yet. Edit: Of all the libraries, AOM is by far the biggest pain in the ass to build, but you'll really get the hang of cmake with that. |
Beta Was this translation helpful? Give feedback.
libheif is going to be a bit of a slog to cut your teeth on, but since you have to start with libde265 anyway, it won't be too bad.
The basic cmake gui is functional enough, point it to the base folder and then pick a build folder anywhere you want, hit configure, pick your build environment. You can choose options there, all you want is to uncheck BUILD_SHARED_LIBS, generate, open project or go find the project files in your build folder, and build.
So opening libheif and changing to a new build folder for that (the UI is clunky about changing projects), configure. Uncheck the same BUILD_SHARED_LIBS, and skip down to LIBDE265_INCLUDE_DIR and LIBDE265_LIBRARY, fill them in appropriately. …