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

Provide artifacts with libtool and pkg-config files #36

Open
joschi opened this issue Jan 20, 2020 · 4 comments
Open

Provide artifacts with libtool and pkg-config files #36

joschi opened this issue Jan 20, 2020 · 4 comments

Comments

@joschi
Copy link
Contributor

joschi commented Jan 20, 2020

Hi!

Thanks for maintaining sharp and these native libraries for libvips! They're a great help to get started. 😃

I'd like to use the native libraries provided by this project in https://github.com/criteo/JVips instead of building the libraries and maintaining their build scripts in JVips, too.

Since it's a Java project using JNI to interface with the native libraries, I need to compile a small wrapper which requires the pkg-config (*.pc) and libtool (*.la) files in order to be build.
Unfortunately, those files are removed at the end of the Linux build script:

sharp-libvips/build/lin.sh

Lines 284 to 285 in 5007da5

cd ${TARGET}/lib
rm -rf pkgconfig .libs *.la libvipsCC* cmake

@lovell Do you think it would be possible and sensible to provider an additional artifact with just these files for people to use the pre-built libraries of sharp-libvips and link them to their own C wrappers?

@lovell
Copy link
Owner

lovell commented Jan 21, 2020

Is this for Linux only? Is it a problem that the .la files might contain hard-coded paths from the build machine?

These files are very small so we could put them in the main tarballs, i.e. not delete them. Happy to accept a PR if you're able.

@kleisauke
Copy link
Collaborator

kleisauke commented Apr 7, 2022

This should be much easier now that we are building a single shared library with all its dependencies statically linked. You only have to include vips-cpp.pc, for example:

prefix=${pcfiledir}/../..
libdir=${prefix}/lib
includedir=${prefix}/include

Name: vips-cpp
Description: C++ API for vips8 image processing library
Version: 8.15.3
Requires:
Libs: -L${libdir} -l:libvips-cpp.so.42
Cflags: -I${includedir} -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include -D_GLIBCXX_USE_CXX11_ABI=0
# Download pre-built libvips binaries
mkdir -p /opt/libvips && cd /opt/libvips
curl -Ls https://github.com/lovell/sharp-libvips/releases/download/v8.15.3/libvips-8.15.3-linux-x64.tar.gz | tar -xzC .

# Download pkgconfig file
mkdir -p lib/pkgconfig && cd lib/pkgconfig
curl -OLs https://gist.github.com/kleisauke/8d93635010b371e154275e376272f8d4/raw/vips-cpp.pc

# Update the PKG_CONFIG_PATH environment variable,
# since libvips is installed in a non-standard prefix
export PKG_CONFIG_PATH=/opt/libvips/lib/pkgconfig

# Ensure dynamic linker finds the pre-built libvips binaries
export LD_LIBRARY_PATH=/opt/libvips/lib

Note that if you need to use the string overload of VImage::new_from_buffer, you must compile your project with -D_GLIBCXX_USE_CXX11_ABI=0. The pre-built binaries were compiled with the devtoolset packages on RHEL/CentOS 7 which forcefully disabled the -D_GLIBCXX_USE_CXX11_ABI=1 compiler flag, see: https://stackoverflow.com/a/52611576.

$ readelf -Ws /opt/libvips/lib/libvips-cpp.so.42 | c++filt | grep -qF "new_from_buffer(std::__cxx11::" && echo "C++11 ABI used" || echo "C++03 ABI used"
C++03 ABI used
$ readelf -Ws /usr/lib64/libvips-cpp.so.42 | c++filt | grep -qF "new_from_buffer(std::__cxx11::" && echo "C++11 ABI used" || echo "C++03 ABI used"
C++11 ABI used

@lovell
Copy link
Owner

lovell commented Aug 13, 2024

Is this still something that might be useful? I guess the vips-cpp.pc file could be published in the @img/sharp-libvips-dev package.

@kleisauke
Copy link
Collaborator

It could still be useful, I think.

FWIW, I just updated https://gist.github.com/kleisauke/8d93635010b371e154275e376272f8d4 to make vips-cpp.pc relocatable, similar to what is done when you build with Meson's pkgconfig.relocatable option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants