System 1: ThinkPad T570, Windows10, QT5.12.2 (Qt Creater 4.8.2)
System 2: NVIDIA Tegra X2, Ubuntu 16.04LTS , QT5.5.1 (Qt Creater 3.5.1)
one, or if it is in .pro file .pri in:
the Qt or pro pri syntax file can only distinguish Windows, Unix, and three Mac OS, Linux should belong in Unix-like operating systems, typically use the following identifiers:
Win32, UNIX, MacX
Example:
in .pro file add the code:
win32{
LIBS +=-L$$PWD -ldemura #in windows system获取当前路径下的demura静态库
}else{
LIBS +=-L./ -ldemora #in linux system获取当前路径下的demora静态库
}
Second, if it is in .h and .cpp file:
Example: get the path in different systems:
QString wstrFilePath;
#if defined(Q_OS_LINUX)
wstrFilePath = qApp->applicationDirPath() + "/../Tx2Oled/2_CAL_G.dat" ;//in linux
#else
wstrFilePath = qApp->applicationDirPath() + "/../../Tx2Oled/2_CAL_G.dat" ;//in windows
#endif
qt定义的各个系统的宏定义:
Q_OS_AIX
Defined on AIX.
Q_OS_ANDROID
Defined on Android.
Q_OS_BSD4
Defined on Any BSD 4.4 system.
Q_OS_BSDI
Defined on BSD/OS.
Q_OS_CYGWIN
Defined on Cygwin.
Q_OS_DARWIN
Defined on Darwin-based operating systems such as macOS, iOS, watchOS, and tvOS.
Q_OS_DGUX
Defined on DG/UX.
Q_OS_DYNIX
Defined on DYNIX/ptx.
Q_OS_FREEBSD
Defined on FreeBSD.
Q_OS_HPUX
Defined on HP-UX.
Q_OS_HURD
Defined on GNU Hurd.
Q_OS_IOS
Defined on ios.
Q_OS_IRIX
Defined on SGI Irix.
Q_OS_LINUX
Defined on Linux.
Q_OS_LYNX
Defined on LynxOS.
Q_OS_MAC
Deprecated synonym for Q_OS_DARWIN. Do not use.
Q_OS_MACOS
Defined on macOS.
Q_OS_NETBSD
Defined on NetBSD.
Q_OS_OPENBSD
Defined on OpenBSD.
Q_OS_OSF
Defined on HP Tru64 UNIX.
Q_OS_OSX
Deprecated synonym for Q_OS_MACOS. Do not use.
Q_OS_QNX
Defined on QNX Neutrino.
Q_OS_RELIANT
Defined on Reliant UNIX.
Q_OS_SCO
Defined on SCO OpenServer 5.
Q_OS_SOLARIS
Defined on Sun Solaris.
Q_OS_TVOS
Defined on tvOS.
Q_OS_ULTRIX
Defined on DEC Ultrix.
Q_OS_UNIX
Defined on Any UNIX BSD/SYSV system.
Q_OS_UNIXWARE
Defined on UnixWare 7, Open UNIX 8.
Q_OS_WATCHOS
Defined on watchOS.
Q_OS_WIN32
Defined on 32-bit and 64-bit versions of Windows.
Q_OS_WIN64
Defined on 64-bit versions of Windows.
Q_OS_WIN
Defined on all supported versions of Windows. That is, if Q_OS_WIN32, Q_OS_WIN64, or Q_OS_WINRT is defined.
Q_OS_WINPHONE
Defined on Windows Phone 8.
Q_OS_WINRT
Defined for Windows Runtime (Windows Store apps) on Windows 8, Windows RT, and Windows Phone 8.
Example: different modes (release and debug) distinction:
#if defined (QT_DEBUG)
qDebug() << "debug mode";
#else
qDebug() << "release mode";
#endif