Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libimagequant_sys: missing shared library #109

Closed
0-wiz-0 opened this issue May 7, 2023 · 5 comments
Closed

libimagequant_sys: missing shared library #109

0-wiz-0 opened this issue May 7, 2023 · 5 comments

Comments

@0-wiz-0
Copy link

0-wiz-0 commented May 7, 2023

The rust version is supposed to replace the C version.
Right now, the rust version only provides a static library.
However, this leads to gd's library only existing as a static library and graphviz having problems, because it wants to build a shared object that's loaded at runtime, for which it would need a shared library.
I have no idea how to do this from rust, but librsvg does provide a shared library, and at least big parts of it are in rust (perhaps there's a C wrapper for the shared object, I haven't looked).
Please provide a shared object for libimagequant. Thanks.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue May 7, 2023
4.x only provides a static library but graphviz needs a shared gd library
PR 57395 and ImageOptim/libimagequant#109
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue May 7, 2023
+ libimagequant-4.2.0
  [ImageOptim/libimagequant#109],
  py-yubikey-manager-5.1.1, ssh-audit-2.9.0, texlab-5.5.1.
@kornelski
Copy link
Member

Rust can build a shared library, but the default cargo build has bad defaults, so it needs an extra help:

cd imagequant-sys/
cargo install cargo-c
cargo cinstall # set appropriately --prefix=/usr/bin --destdir=/

@0323pin
Copy link

0323pin commented May 9, 2023

It seems that the suggested, rust-lang/cargo#5045 (comment) fix to use cdylib-link-lines to generate the shared object is no longer an option as the crate seems to be dead.

Like you pointed on the referenced thread, we are interested in building the share object, not to directly install it as with cargo cinstall. Is there a workaround to generate it inside the "normal" target/release directory?

@kornelski
Copy link
Member

kornelski commented May 9, 2023

cargo cinstall takes --destdir=staging that pretend-installs it in another directory, which you can then package.

Alternatively, modify Cargo.toml and change

[lib]
crate-type = ["staticlib", "lib"]

to

[lib]
crate-type = ["staticlib", "lib", "cdylib"]

to get the default Cargo behavior and a dynamic library in target/release, but due to soname/rpath issues it will work only from the target/ dir, not when installed system-wide. You can fix the shared library to be better behaved if you have tooling to do so.

@0323pin
Copy link

0323pin commented Jul 5, 2023

@kornelski Sorry for nor reporting back earlier, I would say this can be closed now.
We have fixed it following your suggestion of using cargp-c, see package Makefile below:

# $NetBSD: Makefile,v 1.31 2023/06/06 12:41:34 riastradh Exp $

DISTNAME=	libimagequant-4.2.0
CATEGORIES=	graphics
MASTER_SITES+=	${MASTER_SITE_GITHUB:=ImageOptim/}
GITHUB_TAG=	${PKGVERSION_NOREV}

MAINTAINER=	adam@NetBSD.org
HOMEPAGE=	https://pngquant.org/lib/
COMMENT=	High-quality conversion of RGBA images to 8-bit indexed-color
LICENSE=	gnu-gpl-v3

TOOL_DEPENDS+=	cargo-c>=0.9.19:../../devel/cargo-c

WRKSRC=		${WRKDIR}/${DISTNAME}/imagequant-sys

PKGCONFIG_OVERRIDE=		${DESTDIR}${PREFIX}/lib/pkgconfig/imagequant.pc
PKGCONFIG_OVERRIDE_STAGE=	post-install

.include "cargo-depends.mk"

do-install:
	cd ${WRKSRC} && ${RUN} cargo cinstall --destdir=${DESTDIR} --prefix=${PREFIX} --libdir=${PREFIX}/lib

.include "../../lang/rust/cargo.mk"
.include "../../mk/bsd.pkg.mk"

This way it now installs the following files:

include/libimagequant.h
lib/libimagequant.a
lib/libimagequant.so
lib/libimagequant.so.0
lib/libimagequant.so.0.0.0
lib/pkgconfig/imagequant.pc

Unless @0-wiz-0 thinks differently, this is solved.

@0-wiz-0
Copy link
Author

0-wiz-0 commented Jul 5, 2023

Yes, sorry for not giving feedback earlier - cargo cinstall is fine, thanks for the explanations!

@0-wiz-0 0-wiz-0 closed this as completed Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants