首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Qmake创建.pc文件

Qmake创建.pc文件
EN

Stack Overflow用户
提问于 2011-07-26 08:02:08
回答 2查看 2.2K关注 0票数 2

谁知道qmake能不能创建一个.pc文件?我在这里找到了一个说可以的人:http://www.qtcentre.org/threads/24422-How-can-we-create-.pc-file-automatically。但我已经尝试过了,并得到了与在帖子底部有问题的人相同的结果。我想知道是否有人知道这件事。

代码语言:javascript
复制
TEMPLATE = lib
TARGET = proc_Model
QT += declarative dbus
CONFIG += qt plugin dbus create_pc
DESTDIR = /usr/lib/

OBJECTS_DIR = .obj
MOC_DIR = .moc


TARGET = $$qtLibraryTarget($$TARGET)

INCLUDEPATH += ../common 

# Input
SOURCES +=    ../common/proc_struct.cpp \
    listitem.cpp \
    listmodel.cpp \
    process.cpp \
    proc_if.cpp

HEADERS +=  ../common/proc_struct.h \
    listitem.h \
    listmodel.h \
    process.h \
    proc_if.h



headers.path= /usr/include/proc_Model
headers.files = ../common/proc_struct.h \
    listitem.h \
    listmodel.h \
    process.h \
    proc_if.h

target.path = /usr/lib



QMAKE_PKGCONFIG_NAME = proc_Model
QMAKE_PKGCONFIG_DESCRIPTION = Model that emits process info
QMAKE_PKGCONFIG_LIBDIR = $$target.path
QMAKE_PKGCONFIG_INCDIR = $$target.path
QMAKE_PKGCONFIG_DESTDIR = pkgconfig


INSTALLS+=headers target

当我执行install时,我得到了以下输出:

代码语言:javascript
复制
install -m 755 -p "/usr/lib/libproc_Model.so" "/usr/lib/libproc_Model.so"
install: `/usr/lib/libproc_Model.so' and `/usr/lib/libproc_Model.so' are the same file
make: [install_target] Error 1 (ignored)
strip --strip-unneeded "/usr/lib/libproc_Model.so"
install -m 644 -p "/usr/lib/pkgconfig/proc_Model.pc" "/usr/lib/pkgconfig/proc_Model.pc"
install: cannot stat `/usr/lib/pkgconfig/proc_Model.pc': No such file or directory
make: [install_target] Error 1 (ignored)
EN

回答 2

Stack Overflow用户

发布于 2011-08-15 08:49:23

根据qmake源码,您需要添加:

代码语言:javascript
复制
CONFIG += create_prl no_install_prl

create_pc仅使用命令"qmake -prl“将.pc文件目标的规则添加到makefile,并且该命令仅在存在.pc create_prl选项时创建.pc文件。

no_install_prl可防止将由create_prl生成的不需要的.prl文件安装在${target.path}中。

票数 2
EN

Stack Overflow用户

发布于 2018-07-12 05:04:31

我在这里做了一个完整的例子:https://github.com/pvanhoof/dir-examples/blob/master/qmake-example/src/libs/qmake-example/qmake-example.pro

代码语言:javascript
复制
## We get the PREFIX, MAJOR_VERSION, MINOR_VERSION and PATCH_VERSION
## from this project-wide include

include(../../../qmake-example.pri)

## We will use the standard lib template of qmake

TEMPLATE = lib

## We need to set VERSION to a semver.org version for compile_libtool

VERSION = $${MAJOR_VERSION}"."$${MINOR_VERSION}"."$${PATCH_VERSION}

## According https://autotools.io/libtool/version.html, section 4.3
## we should have as target-name the API version in the library's name

TARGET = qmake-example-$${MAJOR_VERSION}"."$${MINOR_VERSION}

## We will write a define in config.h for access to the semver.org
## version as a double quoted string

QMAKE_SUBSTITUTES += config.h.in

## Our example happens to use QDebug, so we need QtCore here

QT = core

## This is of course optional

CONFIG += c++14

## We will be using libtool style libraries

CONFIG += compile_libtool
CONFIG += create_libtool

## These will create a pkg-config .pc file for us

CONFIG += create_pc create_prl no_install_prl

## Project sources

SOURCES = \
    qmake-example.cpp

## Project headers

HEADERS = \
    qmake-example.h

## We will install the headers in a API specific include path

headers.path = $${PREFIX}/include/qmake-example-$${MAJOR_VERSION}"."$${MINOR_VERSION}

## Here will go all the installed headers

headers.files = $${HEADERS}

## Here we will install the library to
target.path = $${PREFIX}/lib

## This is the configuration for generating the pkg-config file

QMAKE_PKGCONFIG_NAME = $${TARGET}
QMAKE_PKGCONFIG_DESCRIPTION = An example that illustrates how to do it right with qmake

# This is our libdir
QMAKE_PKGCONFIG_LIBDIR = $$target.path

# This is where our API specific headers are
QMAKE_PKGCONFIG_INCDIR = $$headers.path
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
QMAKE_PKGCONFIG_PREFIX = $${PREFIX}
QMAKE_PKGCONFIG_VERSION = $$VERSION

## Installation targets (the pkg-config seems to install automatically)

INSTALLS += headers target
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6823862

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档