pkg-config到底是个啥

CMake使用pkg-config # 添加pkg依赖xxx yyy zzz INCLUDE(FindPkgConfig) pkg_check_modules(PKGS_DEP REQUIRED xxx yyy zzz ) # 上面的指令会生成 PKGS_DEP_CFLAGS 和 PKGS_DEP_LDFLAGS # 设置依赖pkg的CGLAGS FOREACH(flag ${PKGS_DEP_CFLAGS}) SET(EXTRA_CFLGAS "${EXTRA_CFLGAS} ${flag}") ENDFOREACH 阅读详情

Pkg-config到底是个啥


😄

Pkgconfig其实跟使用的CMakeList文件中的配置文件作用是一样的,都是为了在需要使用第三方头文件或库文件的时候告诉编译器头文件和库文件的位置

百度百科的解释是

pkg-config 是一个在源代码编译时查询已安装的库的使用接口的计算机工具软件。pkg-config原本是设计用于Linux的,但现在在各个版本的BSD、windows、Mac OS X和Solaris上都有着可用的版本。

使用方法

gcc -o test test.c $(pkg-config --libs --cflags libpng)

当安装一个库的时候,会有一个.pc文件,通过pc文件就能知道所需要的头文件和库所在的位置。

其中cflags指定的是头文件

其中libs指定的是库文件

如何找到pc文件???

在linux系统下面,默认查找的路径是/usr/lib64/pkgconfig

当然可以手动指定,也就是通过设置PKG_CONFIG_PATH这个环境变量来进行指定路径下查找.pc文件

makefile中使用pkgconfig

在Cmake的文件中的时候可以使用FindPkgConfig进行查找pkg-config模块

PKGCONFIG(package includedir libdir linkflags cflags)

例如

PKGCONFIG(libart-2.0 LIBART_INCLUDE_DIR LIBART_LINK_DIR LIBART_LINK_FLAGS LIBART_CFLAGS) 

makefile书写规则

makefile使用

CFLAGS=-Wall -g -std=c++11 `pkg-config --cflags --libs opencv realsense2`

如何编写PC文件

prefix=/home/zhongsy/Downloads/Game/gaminganywhere/deps.posix
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include

Name: libavdevice
Description: FFmpeg device handling library
Version: 56.4.100
Requires: 
Requires.private: libavfilter >= 5.40.101, libswscale >= 3.1.101, libpostproc >= 53.3.100, libavformat >= 56.40.101, libavcodec >= 56.60.100, libswresample >= 1.2.101, libavutil >= 54.31.100
Conflicts:
Libs: -L${libdir}  -lavdevice 
Libs.private: -lXv -lX11 -lXext -lxcb -lxcb-shm -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lxcb-shape -lxcb -lX11 -lsndio -lasound -lxvidcore -L/home/zhongsy/Downloads/Game/gaminganywhere/deps.posix/lib -lx265 -lx264 -lvpx -lm -lvpx -lm -lvpx -lm -lvpx -lm -lvorbisenc -lvorbis -logg -ltheoraenc -ltheoradec -logg -lopus -lmp3lame -lm -llzma -lbz2 -lz -pthread
Cflags: -I${includedir}

在pc文件中主要有的是一下几个变量

  1. Name 名称
  2. Description 描述
  3. version 版本
  4. cflags 所需要使用头文件的目录路径
  5. libs 所需要库文件的目录路径

参考

Cmake findpakage详解

Cmake教程

【ffmpeg源码学习】详解pkg-config的作用 摘要: pkg-config是简化C/C++项目构建的工具,通过查询.pc文件自动获取库的编译链接参数。FFmpeg等库会安装.pc文件,记录头文件路径、库依赖等信息。开发者可通过pkg-config --cflags --libs命令快速生成编译选项,无需手动维护路径。使用时需注意设置PKG_CONFIG_PATH环境变量指向.pc文件目录,并处理可能的动态库路径问题。该工具大幅提升了多库依赖项目的开发效率,但依赖库需正确安装并支持pkg-config机制。 阅读详情

相关推荐

linux基础 - pkg-config工具找库的搜索方式之PKG_CONFIG_PATH

在编译软件项目时,通常需要依赖于各种不同的库文件,这些库文件包含了程序所需的功能和资源。为了正确地编译和链接这些库,开发者需要告诉编译器和链接器库文件的位置。pkg-config 是一个常用的工具,用于帮助开发者查找、配置和获取库文件的信息,从而使编译过程更加简单和可靠。

sz66cm 学习随笔 1371

pkg-config

转载于:https://blog.youkuaiyun.com/newchenxf/article/details/51750239 1 什么是pkg-config pkg-config是一个linux下的命令,用于获得某一个库/模块的所有编译相关的信息。 例子: pkg-config opencv –libs –cflags 结果: -I/usr/include/opencv /usr/l...

junlon2006的博客 1127

编译源码pkg-config报错问题(configure\pkg-config\PKG_CONFIG_PATH关系)

编译源码pkg-config报错问题: … d libraries… yes checking dynamic linker characteristics… (cached) GNU/Linux ld.so checking how to hardcode library paths into programs… immediate checking for pkg-config… /usr/bin/pkg-config checking pkg-config is at least version 0.

weixin_43269452的博客 7826

pkg-config用法详解

在如今这个开源的环境里,想要开发某个功能,我们都会下意识的上网搜索有没有开源库,如果有开源库,那么好,下载下来给它编译好,使用。但是在使用过程中,你是否遇到不知如何将第三方库编译,链接到自己的工程中?怎么改makefile就是改不好?是否看到开源库lib/中pkgconfig文件夹,想都没想这是干什么用的,打开.pc文件也不知所云?那么好,今天我就总结下开源库中pkgconfig文件夹中.pc文件的作用,以及如何用pkg-config工具将开源库集成到自己的工程中去。 1、pkg-config工具的作用

子曰小玖的博客 8881

理解 Linux 下 PKG_CONFIG_LIBDIR 和 PKG_CONFIG_PATH 的作用

pkg-config是一个用于查询已安装软件包的信息的工具,它主要用于检查和获取软件包的编译和链接标志。在交叉编译环境中,这个工具尤为重要,因为它帮助确保正确地定位和使用交叉编译的库和头文件。设置和是在交叉编译环境中确保正确库和头文件定位的关键步骤。这两个环境变量告诉 pkg-config 在哪里寻找.pc文件,以提供正确的库信息。在处理交叉编译环境时,正确配置这些变量是确保项目成功构建的不可或缺的一部分。

dmgy110的博客 2284

RK3588嵌入式AI部署实战:从环境搭建到模型推理全链路

嵌入式AI部署涉及交叉编译、NPU驱动、模型量化与运行时环境等多个技术环节,其核心挑战在于软硬件版本矩阵的严格匹配。在边缘计算场景中,RK3588凭借6TOPS NPU算力成为热门平台,但环境搭建与模型转换的复杂性常导致部署效率低下。通过容器化工具链管理、量化参数对齐及多线程推理优化,可显著提升部署稳定性与推理性能。典型应用包括智能安防、工业质检与视频结构化分析。本文围绕RK3588的AI部署与环境搭建,系统梳理从系统烧录到板端推理的完整实践路径。

weixin_42520573的博客 284

如何安装pkg-config

在搭建go-filecoin测试节点的时候,需要先安装pkg-config,这里介绍在不同系统安装pkg-config的几种方法。 方法一: Mac上,可以直接用brew install pkg-config命令安装。 方法二: Linux上,到pkg-config官网https://www.freedesktop.org/wiki/Software/pkg-config/,下载最新安装包 目前,...

Charliewolf的博客 4万+

第一篇:常见CAN错误帧及其排查方向

在本文中主要阐述各类错误帧的形成原因以及在使用同星硬件设备出现错误帧时,应当 如何进行排查并消除错误帧。在 CAN 总线通信中,通常遇见的错误帧主要为以下五种,其 分别是:bit error、ACK error、stuff error、CRC error 以及 form error。

u013089100的博客 1745

【Linux】PKG_CONFIG_PATH

目录 [ERROR]为了解决以下部署问题 一、什么是configure 二、什么是pkg-config 1、pkg-config介绍 2、pkg-config功能 3、glib-2.0的.pc文件内容举例 4、 环境变量PKG_CONFIG_PATH 三、运行时库的连接 [ERROR]为了解决以下部署问题 Package sentencepiece was not found in the pkg-config search path. Perhaps you shou

qq_36182852的博客 1万+

voc与txt互转

voc2txt # coding:utf-8 from __future__ import print_function import os import random import glob import xml.etree.ElementTree as ET def xml_reader(filename): """ Parse a PASCAL VOC xml file """ tree = ET.parse(filename) size = tree.find('siz

weixin_44898889的博客 826

在ubuntu20.04中安装MATLAB时常见问题及解决方法

   如果你刚装完ubuntu20.04,这时你想要安装MATLAB2021A,在输入命令./install进行安装时,可能会报以下错误:    terminate called after throwing an instance of ‘JailContainerException’ what(): Error: 88: No JRE version parsed from/media/jzx/MATHWORKS_R2021A/sys /java/jre/glnxa64/jre/release   

慕羽★的博客 1万+

pkg-config 详解

1 什么是pkg-config pkg-config是一个linux下的命令,用于获得某一个库/模块的所有编译相关的信息。 例子: pkg-config opencv –libs –cflags 结果: -I/usr/include/opencv /usr/lib/x86_64-linux-gnu/libopencv_calib3d.so /usr/lib/x86_64-linu...

mrwangwang的专栏 7375

从模糊到清晰:让AI教相机自动对焦的实战指南

AI自动对焦技术:让模糊照片成为过去式 深度学习驱动的自动对焦技术正颠覆传统摄影,使相机能在复杂场景下智能锁定焦点。相比传统对焦方法在弱光、低对比度环境下的失效,AI通过学习"清晰-模糊"规律,实现全场景精准对焦。本文详细解析了该技术的三大优势: 自适应各种光线条件; 毫秒级对焦速度; 突破物理限制的精度。 通过PyTorch搭建的CNN模型,展示了从数据采集到模型训练的全流程实战方案,包括使用拉普拉斯算子评估图像清晰度等关键技术。该技术已成功应用于手机摄影、工业检测、无人机航拍和安防监

LXY_LOVE36的博客 348

Linux中pkg-config的使用

pkg-config在编译应用程序和库的时候作为一个工具来使用。pkg-config可以帮助你插入正确的编译选项,而不需要你通过硬编码的方式来找到glib(或其他库)。--cflags一般用于指定头文件,--libs一般用于指定库文件。大家应该都知道一般用第三方库的时候,就少不了要使用到第三方的头文件和库文件。我们在编译、链接的时候,必须要指定这些头文件和库文件的位置。对于一个比较大的第三方库,其头文件和库文件的数量是比较多的,如果我们一个个手动地写,那将是相当的麻烦的。

顺其自然~专栏 8100

17、超声散斑降噪与桌面系统背景估计技术

本文介绍了超声散斑降噪与桌面系统背景估计的先进技术。在超声成像方面,提出结合超分辨率(SR)和非线性扩散(ND)的方法,显著降低噪声并保留图像细节,在MSE和CNR指标上优于传统方法。在桌面交互系统中,针对传统背景估计因忽略设备像素结构导致的误差,提出基于显示器与相机像素结构建模的几何转换方法,有效减少尖锐边缘区域的误检,提升物体识别准确性。实验验证了两种方法的有效性,未来将致力于实时性优化与多设备兼容性扩展。

dream的博客 87

软考高级系统架构设计师系列论文四十九:论微服务架构及其应用

软考高级系统架构设计师系列论文四十九:论微服务架构及其应用

zhengzaifeidelushang的博客 3194

configure、pkg-config、pkg_config_path三者的关系

简述configure、pkg-config、pkg_config_path三者的关系  转自:简述configure、pkg-config、pkg_config_path三者的关系   一、什么是configure   源码安装过程中大多会用到configure...

Jensen Lee的博客 701

新版CKA2020-2020-10-13-真题试卷

2020年10月13日 真题 新版CKA考试已于2020年9月1日正式上线! 考试模式:线上考试 考试时间:2小时 认证有效期:3年 软件版本:Kubernetes v1.19 重考政策:可接受1次重考 经验水平:中級 题目数量:17题 01 Task - 英文 Create a new ClusterRole named deployment-clusterrole that only allows the creation of the following resource types: Depl

随笔记录-分享&记忆 2394

pkg-config 详解

pkg-config是向用户向程序提供相应库的路径、版本号等信息的程序。

若有所思HS 1256

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

pkg-config的用法

pkg-config的用法 pkg-config pkg-config程序是干什么用的?简单的说就是向用户向程序提供相应库的路径、版本号等信息的程序。 譬如说我们运行以下命令: pkg-config 查看gcc的CFLAGS参数 $pkg-config--libs --cflags opencv 会显示如下信息: -I/usr/include/opencv -lcxcore -lc...

weixin_40592935的博客 1049

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

上一篇: game-anywhere介绍
下一篇: 686. 重复叠加字符串匹配
黑猫爱小鹿
博客等级 码龄8年 1万+粉丝 205原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值