简体   繁体   English

是否有用于 pkg-config 的 C/C++ API?

[英]Is there a C/C++ APIfor pkg-config?

I have a strange use case.我有一个奇怪的用例。 I have a C++ program that compiles a library object and dynamically loads it at runtime.我有一个 C++ 程序,它编译一个库 object 并在运行时动态加载它。 The library it compiles depends on a third party dependency, which so far I have been solving by manually hard coding the path and changing it when I switch computers.它编译的库依赖于第三方依赖,到目前为止,我一直在通过手动硬编码路径并在切换计算机时更改它来解决这个问题。

Is there a way to call pkg-config from C++ to ask it if a library is installed and where?有没有办法从 C++ 调用 pkg-config 来询问它是否安装了库以及安装在哪里? I know I could call it from a bash session and parse the output, but this is not what I want, I would like to call it directly instead of invoking a shell if that is possible. I know I could call it from a bash session and parse the output, but this is not what I want, I would like to call it directly instead of invoking a shell if that is possible.

Is there a C/C++ APIfor pkg-config?是否有用于 pkg-config 的 C/C++ API?

Yes, there is a C api.是的,有一个 C api。 https://github.com/pkgconf/pkgconf/blob/master/libpkgconf/libpkgconf.h , which should get installed with libpkgconf.so shared library. https://github.com/pkgconf/pkgconf/blob/master/libpkgconf/libpkgconf.h ,它应该与libpkgconf.so共享库一起安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM