gpt4 book ai didi

c++ - qmake 与 Jenkins

转载 作者:搜寻专家 更新时间:2023-10-31 02:15:09 25 4
gpt4 key购买 nike

每当我将提交提交到 Git 时,我都试图让 Jenkins 为我进行编译和构建。我有一个在 Qt Creator 中创建的 helloworld 应用程序。它确实在 Qt Creator 中编译和构建,它确实显示在我的手机上,但它不想用 Jenkins 编译和构建。

我正在使用 QtC 使用的相同 shell 命令:

qmake helloworld.pro -r -spec android-g++;
make;

控制台输出为:

+ qmake helloworld.pro -r -spec android-g++
+ make
/home/ndk/toolchains/arm-linux-androideabi-4.9-/prebuilt/bin/arm-linux-androideabi-g++ -c -pipe -std=c++11 -O2 -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -Wall -Wno-psabi -W -I/usr/share/qt4/mkspecs/android-g++ -I. -I. -I/home/ndk/sources/cxx-stl/gnu-libstdc++//include -I/home/ndk/sources/cxx-stl/gnu-libstdc++//libs//include -I/home/ndk/platforms//arch-arm//usr/include -o main.o main.cpp
In file included from main.cpp:1:0:
mainwindow.h:4:23: fatal error: QMainWindow: No such file or directory
#include <QMainWindow>
^
compilation terminated.
Makefile:187: recipe for target 'main.o' failed
make: *** [main.o] Error 1

我的 helloworld.pro:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = helloworld
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui

CONFIG += mobility
MOBILITY =

main.cpp

#include "mainwindow.h"
#include <QMainWindow>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();

return a.exec();
}

编辑/更新:

到目前为止,我已经尝试指定 qmake 的完整路径,以确保我使用 Qt 的 qmake。

/home/qt/5.7/android_armv7/bin/qmake helloworld.pro -r -spec android-g++;
make;

输出是:

/home/qt/5.7/android_armv7/bin/uic mainwindow.ui -o ui_mainwindow.h
/home/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -c -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -DANDROID -Wa,--noexecstack -fno-builtin-memmove -std=c++11 -O2 -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -Wall -Wno-psabi -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../qt/5.7/android_armv7/include -I../../qt/5.7/android_armv7/include/QtWidgets -I../../qt/5.7/android_armv7/include/QtGui -I../../qt/5.7/android_armv7/include/QtCore -I. -I. -I../../ndk/sources/cxx-stl/gnu-libstdc++/4.9/include -I../../ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I../../ndk/platforms/android-9/arch-arm/usr/include -I../../qt/5.7/android_armv7/mkspecs/android-g++ -o main.o main.cpp
/home/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -c -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -DANDROID -Wa,--noexecstack -fno-builtin-memmove -std=c++11 -O2 -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -Wall -Wno-psabi -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../qt/5.7/android_armv7/include -I../../qt/5.7/android_armv7/include/QtWidgets -I../../qt/5.7/android_armv7/include/QtGui -I../../qt/5.7/android_armv7/include/QtCore -I. -I. -I../../ndk/sources/cxx-stl/gnu-libstdc++/4.9/include -I../../ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I../../ndk/platforms/android-9/arch-arm/usr/include -I../../qt/5.7/android_armv7/mkspecs/android-g++ -o mainwindow.o mainwindow.cpp
mainwindow.cpp:3:25: fatal error: QtGui/QAction: No such file or directory
#include <QtGui/QAction>
^
compilation terminated.
Makefile:1780: recipe for target 'mainwindow.o' failed
make: *** [mainwindow.o] Error 1

最佳答案

很可能您的 jenkins 设置使用了错误的 qmake。 Qt 安装与其 qmake 之间存在 1:1 的映射关系。因此,您安装的 Qt for android 将有自己的 qmake,您必须通过完整路径引用它! Qt Creator 设置路径以便自动发生这种情况,Jenkins 不会 - 而且无论如何也不应该。

为任何特定的 Qt 版本构建时,您只需要显式调用其 qmake。从那时起,只要正确的编译器在路径中,事情就会按预期发生,您再也不需要手动引用该 Qt 版本。 makefile 将全部引用该 Qt 安装中的 Qt 库、头文件和工具。

您也不需要 -spec 参数。每个 Qt 安装都针对特定的 mkspec 进行编译,因此 qmake 本身确切地知道该规范是什么。我不知道为什么 QtCreator 会给出这样的论点,这没有多大意义。

关于c++ - qmake 与 Jenkins ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39017939/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com