How to write a file PkgConfig.pc file that supports both static and shared linking
2
votes
1
answer
1136
views
I am writing a little library as a self challenge. I plan to target Linux based systems.
I want to add a
libname.pc
file so as to add support for PkgConfig
.
Here, is my current file:
prefix=/usr/local
exec_prefix=${prefix}
cphoton_directory=cphoton-0.0
include_directory=${prefix}/include/${cphoton_directory}
library_directory=${exec_prefix}/lib
Name: cphoton-0.0
Description: CPhoton is a basic utility library.
Version: 0.0.0
URL: https://gitlab.com/invitron/cphoton
Cflags: -I${include_directory}
Libs: -L${library_directory} -lcphoton-0.0
Libs.private:
I wanted to know if this is compatible for both static and dynamic libs. I tried to use pkg-config with --static
flag but, it seems to give precedence to .so
lib. I also tested it with cmake. It links statically only if the dynamic lib is not available.
Is it possible or will I have to provide a separate .pc
file for static version?
Already visited:
- https://stackoverflow.com/questions/27586503/how-to-use-pkg-config-to-link-a-library-statically
- https://people.freedesktop.org/~dbn/pkg-config-guide.html
Asked by Mansoor Ahmed Memon
(138 rep)
Dec 5, 2020, 04:46 PM
Last activity: Jun 9, 2024, 08:09 PM
Last activity: Jun 9, 2024, 08:09 PM