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

Add depended on libraries and C++ runtime to link to in pkg-config file #119

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

robUx4
Copy link

@robUx4 robUx4 commented Sep 5, 2022

When linking statically with chromaprint the app needs to know which libraries to link with. It also needs the C++ runtime if the calling code doesn't have any C++.

thresheek and others added 2 commits September 5, 2022 16:09
- Moved AVFFT check: FFMPEG_LIBRARIES might be unset even if
all needed FFmpeg libraries were found.
- Added an ability to link with VDSP/Accelerate Framework on macOS.
gcc needs libstdc++ and clang needs libc++.
@robUx4
Copy link
Author

robUx4 commented Sep 6, 2022

This is needed when the host app is coded in C and has no idea that chromaprint uses C++ internally.

vlc-mirrorer pushed a commit to videolan/vlc that referenced this pull request Sep 7, 2022
@lalinsky
Copy link
Member

lalinsky commented Nov 4, 2022

@robUx4 Could you post the diff of the pkg-config config on all platforms? The change are kind of hard to review and the diffs would help a lot.

@sebastinas
Copy link

As the C++ library is only needed for static linking, this should be added only to Libs.private if at all.

@lalinsky
Copy link
Member

Indeed and static linking is tricky for multiple reasons, it's much better to just include the libraries needed for the particular build in the project's build system.

@robUx4
Copy link
Author

robUx4 commented Nov 15, 2022

On a Linux build, Before:

Name: chromaprint
Description: Audio fingerprint library
URL: http://acoustid.org/chromaprint
Version: 1.4.2
Libs: -L/root/build/contrib/x86_64-linux-gnu/lib -lchromaprint
Cflags: -I/root/build/contrib/x86_64-linux-gnu/include

After:

Name: chromaprint
Description: Audio fingerprint library
URL: http://acoustid.org/chromaprint
Version: 1.4.2
Libs: -L/root/build/contrib/x86_64-linux-gnu/lib -lchromaprint -L/root/build/contrib/x86_64-linux-gnu/lib -lavcodec -pthread -lm -latomic -lz -lgsm -lmp3lame -lm -lopenjp2 -lm -lavutil -pthread -lm -latomic -lstdc++ -lm -lc
Cflags: -I/root/build/contrib/x86_64-linux-gnu/include

I agree it my be better in Libs.private. Things like -pthread also don't belong here. Other dependencies like zlib might be handled through Requires: but that's a bit more work.

The C++ runtime to use is needed because the library can be used with a C interface. The host app cannot guess what it really needs to link to. When used from C++ code it will pick its own runtime (and should match the one from the library).

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

Successfully merging this pull request may close these issues.

None yet

4 participants