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 中定义的变量
  • $$()可以用来取值 系统环境变量 中的变量
相关推荐
huohaiyu1 小时前
Hashtable,HashMap,ConcurrentHashMap之间的区别
java·开发语言·多线程·哈希
Predestination王瀞潞5 小时前
IO操作(Num22)
开发语言·c++
宋恩淇要努力6 小时前
C++继承
开发语言·c++
沿着路走到底7 小时前
python 基础
开发语言·python
沐知全栈开发8 小时前
C# 委托(Delegate)
开发语言
任子菲阳9 小时前
学Java第三十四天-----抽象类和抽象方法
java·开发语言
csbysj20209 小时前
如何使用 XML Schema
开发语言
R6bandito_10 小时前
STM32中printf的重定向详解
开发语言·经验分享·stm32·单片机·嵌入式硬件·mcu
earthzhang202110 小时前
【1007】计算(a+b)×c的值
c语言·开发语言·数据结构·算法·青少年编程
杨枝甘露小码10 小时前
Python学习之基础篇
开发语言·python