QT跨平台开发(windows、mac)中.pro文件设置

方法一: 在配置前面加上平台标识符的前缀

cpp 复制代码
# windows
win32:INCLUDEPATH += F:/Dev/ffmpeg-4.3.2/include
win32:LIBS += -LF:/Dev/ffmpeg-4.3.2/lib \
              -lavcodec \
              -lavdevice \
              -lavfilter \
              -lavformat \
              -lavutil \
              -lpostproc \
              -lswscale \
              -lswresample
 
# mac
macx:INCLUDEPATH += /usr/local/Cellar/ffmpeg/4.3.2/include
macx:LIBS += -L/usr/local/Cellar/ffmpeg/4.3.2/lib \
            -lavcodec \
            -lavdevice \
            -lavfilter \
            -lavformat \
            -lavutil \
            -lpostproc \
            -lswscale \
            -lswresample \
            -lavresample
 
# linux
# linux:INCLUDEPATH += ...
# linux:LIBS += ...

或使用 大括号 简化:

cpp 复制代码
# windows
win32 {
    INCLUDEPATH += F:/Dev/ffmpeg-4.3.2/include
    LIBS += -LF:/Dev/ffmpeg-4.3.2/lib \
            -lavcodec \
            -lavdevice \
            -lavfilter \
            -lavformat \
            -lavutil \
            -lpostproc \
            -lswscale \
            -lswresample
}
 
# mac
macx {
    INCLUDEPATH += /usr/local/Cellar/ffmpeg/4.3.2/include
    LIBS += -L/usr/local/Cellar/ffmpeg/4.3.2/lib \
            -lavcodec \
            -lavdevice \
            -lavfilter \
            -lavformat \
            -lavutil \
            -lpostproc \
            -lswscale \
            -lswresample \
            -lavresample
}

方法二:将公共信息抽取成变量,然后使用$${}去访问

使用$${}去访问

cpp 复制代码
# mac
macx {
    FFMPEG_HOME = /usr/local/Cellar/ffmpeg/4.3.2
    INCLUDEPATH += $${FFMPEG_HOME}/include
    LIBS += -L$${FFMPEG_HOME}/lib \
            -lavcodec \
            -lavdevice \
            -lavfilter \
            -lavformat \
            -lavutil \
            -lpostproc \
            -lswscale \
            -lswresample \
            -lavresample
}
  • message()可以用来打印
  • $${}可以用来取值: .pro 中定义的变量
  • $$()可以用来取值 系统环境变量 中的变量
相关推荐
myloveasuka5 小时前
Java与C++多态访问成员变量/方法 对比
java·开发语言·c++
2301_821700535 小时前
C++编译期多态实现
开发语言·c++·算法
奥地利落榜美术生灬6 小时前
c++ 锁相关(mutex 等)
开发语言·c++
xixihaha13246 小时前
C++与FPGA协同设计
开发语言·c++·算法
重庆小透明6 小时前
【java基础篇】详解BigDecimal
java·开发语言
ID_180079054736 小时前
模拟1688商品详情的Python API实现,返回符合风格的JSON数据
开发语言·python·json
小小怪7506 小时前
C++中的函数式编程
开发语言·c++·算法
金山几座6 小时前
C#学习记录-事件
开发语言·学习·c#
小杍随笔7 小时前
【Rust 语言编程知识与应用:基础数据类型详解】
开发语言·后端·rust
Yupureki7 小时前
《MySQL数据库基础》1. 数据库基础
c语言·开发语言·数据库·c++·mysql·oracle·github