Qt pro文件下跨平台宏的使用(windows/linux 以及x86 和 arm的区分)

#Qt pro文件下跨平台宏的使用(windows/linux 以及x86 和 arm的区分)

在pro文件中添加:

#仅在linux 系统下, 硬件平台无关的内容
unix{
    HEADERS += \

    SOURCES += \
        Manager.cpp \
}

#arm64 的编译宏
contains(QMAKE_HOST.arch, aarch64){
#aarch64 是编译器类型,如果不是这个编译器, 可以把.arch 替换成对应的类型
#arm 64平台
    INCLUDEPATH += $$PWD/../commonLibrary/lib/mqtt/qmqtt
    DEPENDPATH += $$PWD/../commonLibrary/lib/mqtt

    INCLUDEPATH += $$PWD/../commonLibrary/include
    DEPENDPATH += $$PWD/../commonLibrary/include

    LIBS += -L$$PWD/../commonLibrary/lib/arm64/ -lQt5Qmqtt
message("编译目标平台: arm-64")
message("编译器平台类型: $$QMAKE_HOST.arch")
}else{
message("编译目标平台: x86")
message("编译器平台类型: $$QMAKE_HOST.arch")
#x86平台
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../commonLibrary/lib/windows/win32/ -lQt5Qmqtt
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../commonLibrary/lib/windows/win32/ -lQt5Qmqtt
    else:unix: LIBS += -L$$PWD/../commonLibrary/lib/mqtt/ -lqmqtt

    INCLUDEPATH += $$PWD/../commonLibrary/lib/mqtt
    DEPENDPATH += $$PWD/../commonLibrary/lib/windows/win64

   win32{
   # 仅x86-windows下的

    }

#仅在linux -x86 平台下的内容
    unix{
        HEADERS += \
            Manager.h \

        SOURCES += \
            Manager.cpp \


        unix: LIBS += -L$$PWD/../commonLibrary/lib/ -lmsc

        LIBS += -lasound
    }
}

你可能感兴趣的:(windows相关,Qt相关,linux相关)