Docker 容器中的 MXE Qt5 应用程序构建失败
MXE Qt5 application builds fail in Docker container
所以,我已经在 Docker 容器(基于 Ubuntu 18.04)中成功构建了 MXE 和 Qt5 (make qt5
),并复制了 /opt/mxe
中的内容,附加 PATH
和 /opt/mxe/usr/bin
.
但是,当我尝试在容器内构建我的 Qt5 应用程序时,qmake 和 CMake 都失败了。由于某种原因,Qt 工具无法正常工作。这是 qmake 的输出:
# i686-w64-mingw32.static-qmake-qt5 ../heimer.pro
Project MESSAGE: Building for Qt version 5.11.1.
Project MESSAGE: Building for Qt version 5.11.1.
Project MESSAGE: Building for Qt version 5.11.1.
RCC: Error in '../data/icons/icons.qrc': Cannot find file 'heimer.png'
RCC: Warning: No resources in '../data/icons/icons.qrc'.
RCC: Error in '../data/images/images.qrc': Cannot find file 'about.png'
RCC: Error in '../data/images/images.qrc': Cannot find file 'add.png'
RCC: Error in '../data/images/images.qrc': Cannot find file 'colors.png'
RCC: Warning: No resources in '../data/images/images.qrc'.
RCC: Error in '../data/translations/translations.qrc': Cannot find file 'heimer_fi.qm'
RCC: Warning: No resources in '../data/translations/translations.qrc'.
RCC: Error in '../data/icons/icons.qrc': Cannot find file 'heimer.png'
RCC: Warning: No resources in '../data/icons/icons.qrc'.
RCC: Error in '../data/images/images.qrc': Cannot find file 'about.png'
RCC: Error in '../data/images/images.qrc': Cannot find file 'add.png'
RCC: Error in '../data/images/images.qrc': Cannot find file 'colors.png'
RCC: Warning: No resources in '../data/images/images.qrc'.
RCC: Error in '../data/translations/translations.qrc': Cannot find file 'heimer_fi.qm'
RCC: Warning: No resources in '../data/translations/translations.qrc'.
资源编译器找不到任何东西。
CMake 构建失败如下:
# i686-w64-mingw32.static-cmake --build .
== Using MXE wrapper: /opt/mxe/usr/bin/i686-w64-mingw32.static-cmake
== Skip using MXE toolchain: /opt/mxe/usr/i686-w64-mingw32.static/share/cmake/mxe-conf.cmake
Scanning dependencies of target heimer_autogen
[ 1%] Automatic MOC for target heimer
AutoMoc subprocess error
------------------------
moc failed for "/heimer/src/nodehandle.hpp"
Command
-------
/opt/mxe/usr/i686-w64-mingw32.static/qt5/bin/moc -I/heimer/build-mxe-cmake-docker/src -I/heimer/src -I/heimer/build-mxe-cmake-docker /src/heimer_autogen/include -I/heimer/src/contrib -I/heimer/build-mxe-cmake-docker -I/opt/mxe/usr/i686-w64-mingw32.static/qt5/include -I/opt/mxe/usr/i686-w64-mingw32.static/qt5/include/QtWidgets -I/opt/mxe/usr/i686-w64-mingw32.static/qt5/include/QtGui -I/opt/mxe/usr/i686-w64-mingw32.static/qt5/include/QtCore -I/opt/mxe/usr/i686-w64-mingw32.static/qt5/./mkspecs/win32-g++ -I/opt/mxe/usr/i686-w64-mingw32.static/qt5/include/QtXml -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_XML_LIB "-DVERSION=\"0.0.0\"" -o /heimer/build-mxe-cmake-docker/src/heimer_autogen/EWIEGA46WW/moc_nodehandle.cpp /heimer/src/nodehandle.hpp
Output
------
/heimer/src/nodehandle.hpp:28: Error: Undefined interface
让我们检查一下容器内的Qt配置:
# /opt/mxe/usr/bin/i686-w64-mingw32.static-qmake-qt5 -query
QT_SYSROOT:
QT_INSTALL_PREFIX:/opt/mxe/usr/i686-w64-mingw32.static/qt5
QT_INSTALL_ARCHDATA:/opt/mxe/usr/i686-w64-mingw32.static/qt5
QT_INSTALL_DATA:/opt/mxe/usr/i686-w64-mingw32.static/qt5
QT_INSTALL_DOCS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/doc
QT_INSTALL_HEADERS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/include
QT_INSTALL_LIBS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/lib
QT_INSTALL_LIBEXECS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/bin
QT_INSTALL_BINS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/bin
QT_INSTALL_TESTS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/tests
QT_INSTALL_PLUGINS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/plugins
QT_INSTALL_IMPORTS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/imports
QT_INSTALL_QML:/opt/mxe/usr/i686-w64-mingw32.static/qt5/qml
QT_INSTALL_TRANSLATIONS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/translations
QT_INSTALL_CONFIGURATION:/opt/mxe/usr/i686-w64-mingw32.static/qt5/etc/xdg
QT_INSTALL_EXAMPLES:/opt/mxe/usr/i686-w64-mingw32.static/qt5/examples
QT_INSTALL_DEMOS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/examples
QT_HOST_PREFIX:/opt/mxe/usr/i686-w64-mingw32.static/qt5
QT_HOST_DATA:/opt/mxe/usr/i686-w64-mingw32.static/qt5
QT_HOST_BINS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/bin
QT_HOST_LIBS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/lib
QMAKE_SPEC:linux-g++
QMAKE_XSPEC:win32-g++
QMAKE_VERSION:3.1
QT_VERSION:5.11.1
好像没问题。
当然,无论是否使用 MXE 以及 qmake 和 CMake,我的应用程序都能在我的主机上完美编译。
有什么想法吗?
运行 带有 --privileged
的 docker 容器解决了这个问题。
所以,我已经在 Docker 容器(基于 Ubuntu 18.04)中成功构建了 MXE 和 Qt5 (make qt5
),并复制了 /opt/mxe
中的内容,附加 PATH
和 /opt/mxe/usr/bin
.
但是,当我尝试在容器内构建我的 Qt5 应用程序时,qmake 和 CMake 都失败了。由于某种原因,Qt 工具无法正常工作。这是 qmake 的输出:
# i686-w64-mingw32.static-qmake-qt5 ../heimer.pro
Project MESSAGE: Building for Qt version 5.11.1.
Project MESSAGE: Building for Qt version 5.11.1.
Project MESSAGE: Building for Qt version 5.11.1.
RCC: Error in '../data/icons/icons.qrc': Cannot find file 'heimer.png'
RCC: Warning: No resources in '../data/icons/icons.qrc'.
RCC: Error in '../data/images/images.qrc': Cannot find file 'about.png'
RCC: Error in '../data/images/images.qrc': Cannot find file 'add.png'
RCC: Error in '../data/images/images.qrc': Cannot find file 'colors.png'
RCC: Warning: No resources in '../data/images/images.qrc'.
RCC: Error in '../data/translations/translations.qrc': Cannot find file 'heimer_fi.qm'
RCC: Warning: No resources in '../data/translations/translations.qrc'.
RCC: Error in '../data/icons/icons.qrc': Cannot find file 'heimer.png'
RCC: Warning: No resources in '../data/icons/icons.qrc'.
RCC: Error in '../data/images/images.qrc': Cannot find file 'about.png'
RCC: Error in '../data/images/images.qrc': Cannot find file 'add.png'
RCC: Error in '../data/images/images.qrc': Cannot find file 'colors.png'
RCC: Warning: No resources in '../data/images/images.qrc'.
RCC: Error in '../data/translations/translations.qrc': Cannot find file 'heimer_fi.qm'
RCC: Warning: No resources in '../data/translations/translations.qrc'.
资源编译器找不到任何东西。
CMake 构建失败如下:
# i686-w64-mingw32.static-cmake --build .
== Using MXE wrapper: /opt/mxe/usr/bin/i686-w64-mingw32.static-cmake
== Skip using MXE toolchain: /opt/mxe/usr/i686-w64-mingw32.static/share/cmake/mxe-conf.cmake
Scanning dependencies of target heimer_autogen
[ 1%] Automatic MOC for target heimer
AutoMoc subprocess error
------------------------
moc failed for "/heimer/src/nodehandle.hpp"
Command
-------
/opt/mxe/usr/i686-w64-mingw32.static/qt5/bin/moc -I/heimer/build-mxe-cmake-docker/src -I/heimer/src -I/heimer/build-mxe-cmake-docker /src/heimer_autogen/include -I/heimer/src/contrib -I/heimer/build-mxe-cmake-docker -I/opt/mxe/usr/i686-w64-mingw32.static/qt5/include -I/opt/mxe/usr/i686-w64-mingw32.static/qt5/include/QtWidgets -I/opt/mxe/usr/i686-w64-mingw32.static/qt5/include/QtGui -I/opt/mxe/usr/i686-w64-mingw32.static/qt5/include/QtCore -I/opt/mxe/usr/i686-w64-mingw32.static/qt5/./mkspecs/win32-g++ -I/opt/mxe/usr/i686-w64-mingw32.static/qt5/include/QtXml -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_XML_LIB "-DVERSION=\"0.0.0\"" -o /heimer/build-mxe-cmake-docker/src/heimer_autogen/EWIEGA46WW/moc_nodehandle.cpp /heimer/src/nodehandle.hpp
Output
------
/heimer/src/nodehandle.hpp:28: Error: Undefined interface
让我们检查一下容器内的Qt配置:
# /opt/mxe/usr/bin/i686-w64-mingw32.static-qmake-qt5 -query
QT_SYSROOT:
QT_INSTALL_PREFIX:/opt/mxe/usr/i686-w64-mingw32.static/qt5
QT_INSTALL_ARCHDATA:/opt/mxe/usr/i686-w64-mingw32.static/qt5
QT_INSTALL_DATA:/opt/mxe/usr/i686-w64-mingw32.static/qt5
QT_INSTALL_DOCS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/doc
QT_INSTALL_HEADERS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/include
QT_INSTALL_LIBS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/lib
QT_INSTALL_LIBEXECS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/bin
QT_INSTALL_BINS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/bin
QT_INSTALL_TESTS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/tests
QT_INSTALL_PLUGINS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/plugins
QT_INSTALL_IMPORTS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/imports
QT_INSTALL_QML:/opt/mxe/usr/i686-w64-mingw32.static/qt5/qml
QT_INSTALL_TRANSLATIONS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/translations
QT_INSTALL_CONFIGURATION:/opt/mxe/usr/i686-w64-mingw32.static/qt5/etc/xdg
QT_INSTALL_EXAMPLES:/opt/mxe/usr/i686-w64-mingw32.static/qt5/examples
QT_INSTALL_DEMOS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/examples
QT_HOST_PREFIX:/opt/mxe/usr/i686-w64-mingw32.static/qt5
QT_HOST_DATA:/opt/mxe/usr/i686-w64-mingw32.static/qt5
QT_HOST_BINS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/bin
QT_HOST_LIBS:/opt/mxe/usr/i686-w64-mingw32.static/qt5/lib
QMAKE_SPEC:linux-g++
QMAKE_XSPEC:win32-g++
QMAKE_VERSION:3.1
QT_VERSION:5.11.1
好像没问题。
当然,无论是否使用 MXE 以及 qmake 和 CMake,我的应用程序都能在我的主机上完美编译。
有什么想法吗?
运行 带有 --privileged
的 docker 容器解决了这个问题。