我正在使用Qmake和QtCreator进行交叉编译。在套件的设置中(工具链和qmake详细信息在那里设置),有一个名为Sysroot:
的字段。
(Example here)
由于QtCreator和Qmake最终负责生成Makefile,我的问题是,该选项在Makefile中转换为什么以及如何将其传递给工具链?
问题的动机
我Sysroot:
指向~/path-to-sysroot
。 ~/path-to-sysroot
包含为嵌入式目标交叉编译的常规sysroot结构。
~/path-to-sysroot
├── bin
├── include
├── lib
├── sbin
├── share
└── usr
当我尝试交叉编译一些依赖于~/path-to-sysroot/usr/lib
中的库的代码时,它失败并显示缺少lib的消息,但是存在。我已经解析了生成的makefile,但没有发现~/path-to-sysroot/usr/lib
的痕迹。
答案 0 :(得分:1)
来自:http://doc.qt.io/qt-5/qt-conf.html
qt.conf文件可用于覆盖编译到Qt库中的硬编码路径。可以使用QLibraryInfo类访问这些路径。如果没有qt.conf,QLibraryInfo中的函数将返回这些硬编码路径;否则他们返回qt.conf中指定的路径。
如果没有qt.conf,Qt库将使用硬编码路径来查找插件,翻译等。这些路径可能不存在于目标系统上,或者可能无法访问。因此,您可能需要使用qt.conf来使Qt库看起来在其他位置。
qmake -query
QT_SYSROOT:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux
QT_INSTALL_PREFIX:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr
QT_INSTALL_PREFIX/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr
QT_INSTALL_ARCHDATA:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib/qt5
QT_INSTALL_ARCHDATA/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib/qt5
QT_INSTALL_DATA:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/share/qt5
QT_INSTALL_DATA/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/share/qt5
QT_INSTALL_DOCS:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/share/doc/qt5
QT_INSTALL_DOCS/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/share/doc/qt5
QT_INSTALL_HEADERS:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/include/qt5
QT_INSTALL_HEADERS/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/include/qt5
QT_INSTALL_LIBS:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib
QT_INSTALL_LIBS/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib
QT_INSTALL_LIBEXECS:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib/qt5/libexec
QT_INSTALL_LIBEXECS/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib/qt5/libexec
QT_INSTALL_BINS:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/bin/qt5
QT_INSTALL_BINS/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/bin/qt5
QT_INSTALL_TESTS:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/share/qt5/tests
QT_INSTALL_TESTS/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/share/qt5/tests
QT_INSTALL_PLUGINS:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib/qt5/plugins
QT_INSTALL_PLUGINS/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib/qt5/plugins
QT_INSTALL_IMPORTS:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib/qt5/imports
QT_INSTALL_IMPORTS/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib/qt5/imports
QT_INSTALL_QML:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib/qt5/qml
QT_INSTALL_QML/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib/qt5/qml
QT_INSTALL_TRANSLATIONS:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/share/qt5/translations
QT_INSTALL_TRANSLATIONS/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/share/qt5/translations
QT_INSTALL_CONFIGURATION:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/etc/qt5
QT_INSTALL_CONFIGURATION/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/etc/qt5
QT_INSTALL_EXAMPLES:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/examples
QT_INSTALL_EXAMPLES/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/examples
QT_INSTALL_DEMOS:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/examples
QT_INSTALL_DEMOS/raw:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/examples
QT_HOST_PREFIX:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr
QT_HOST_DATA:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib/qt5
QT_HOST_BINS:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/bin/qt5
QT_HOST_LIBS:/opt/mel/next+snapshot/sysroots/i686-melsdk-linux/usr/lib
QT_EXTERNAL_HOST_BINS:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/usr/bin/qt5
QMAKE_SPEC:/home/mentor/work/git/mel_repos/mel_cedar/build/tmp/sysroots/x86_64-linux/usr/lib/qt5/mkspecs/linux-oe-g++
QMAKE_XSPEC:linux-oe-g++
QMAKE_VERSION:3.0
QT_VERSION:5.4.1
qmake不使用sysroot参数,它包含所有路径。您可以通过覆盖qt.conf中的那些路径来自定义qmake,但它仍然没有显示sysroot的路径。而且我认为它没有任何选择来指定sysroot。您必须在qtcreator
中的Compiler标志中手动设置sysroot