libheif-rs icon indicating copy to clipboard operation
libheif-rs copied to clipboard

statically linking libheif

Open woelper opened this issue 1 year ago • 11 comments

Hi, and thank you for this great library!

I am trying to statically link libheif to make distribution of my program easier and not have the user install libheif individually. Is there a recommended or even built-in way of doing so?

woelper avatar Feb 26 '24 19:02 woelper

I'm afraid, I don't know how to do it. I've never done it before.

Cykooz avatar Feb 26 '24 20:02 Cykooz

Hi, and thank you for this great library!

I am trying to statically link libheif to make distribution of my program easier and not have the user install libheif individually. Is there a recommended or even built-in way of doing so?

I'm pretty new to rust but doesn't rust embed libraries in executable at build time?

neckaros avatar Mar 03 '24 08:03 neckaros

I'm pretty new to rust but doesn't rust embed libraries in executable at build time?

C libraries are manually dynamically linked. This has nothing to do with how rust crates work.

sophie-h avatar Mar 03 '24 12:03 sophie-h

How to support compiling into wasm?

JokerAJP avatar Mar 04 '24 07:03 JokerAJP

How to support compiling into wasm?

According to the Internet it is a very painful task.

Cykooz avatar Apr 23 '24 21:04 Cykooz

Also you have to consider that libheif is licensed under LGPL v3.

So if you want to distribute a combined work, you'll have to use the following license:

  • statically linked:
    • Either you must release both parts as LGPL.
    • Or provide everything that allow the user to relink the application with a different version of the LGPL source code. In this case the other requirements are the same as if it was dynamically linked.
  • dynamically linked: LGPL code stays LGPL, you can keep the proprietary code proprietary.

Source - https://stackoverflow.com/a/10179181

Cykooz avatar May 12 '24 16:05 Cykooz

Hi, and thank you for this great library!

I am trying to statically link libheif to make distribution of my program easier and not have the user install libheif individually. Is there a recommended or even built-in way of doing so?

@woelper Did you succeed in statically linking libheif ?

neckaros avatar Jun 28 '24 12:06 neckaros

Not completely. I managed to get some success on windows, but not on other platforms.

woelper avatar Jul 01 '24 13:07 woelper

I know this is not Rust, but someone got it working by compiling libheif to WASM using emscripten and running it that way https://github.com/jerbob92/goheif/blob/feature/webassembly/libde265/libde265.go

Thanks to this guy, now my mom can access her photos

ForestJohnson avatar Jul 21 '24 04:07 ForestJohnson

Also you have to consider that libheif is licensed under LGPL v3.

@Cykooz, has the license changed since then, or did I miss something?

C.f. libheif/README.md#license

The libheif is distributed under the terms of the GNU Lesser General Public License. The sample applications are distributed under the terms of the MIT License.

vincent-herlemont avatar Jul 22 '24 17:07 vincent-herlemont

has the license changed since then, or did I miss something?

GNU Lesser General Public License - LGPL. Nothing has changed.

Cykooz avatar Jul 22 '24 20:07 Cykooz