在发布模式下启动以库的静态链接编译的应用程序时出错。

问题描述 投票:0回答:1

在调试模式下编译时,我的应用程序可以启动和运行,并且成功。同时,在发布模式下编译也没有给出任何错误。

21:45:27: Launch: "D:\TTTTTTTTTTTTTTTTTTTTTTTTTTT\qt\Tools\mingw730_64\bin\mingw32-make.exe" -j4
D:\TTTTTTTTTTTTTTTTTTTTTTTTTTT\qt\5.12.7\mingw73_64\bin\qmake.exe -o Makefile ..\B\B.pro -spec win32-g++ "CONFIG+=qtquickcompiler"
D:/TTTTTTTTTTTTTTTTTTTTTTTTTTT/qt/Tools/mingw730_64/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'C:/Users/**/Desktop/gl/2/BattleShips/build-B-Desktop_Qt_5_12_7_MinGW_64_bit-Release'
mingw32-make[1]: Nothing to be done for 'first'.
mingw32-make[1]: Leaving directory 'C:/Users/**/Desktop/**/2/BattleShips/build-B-Desktop_Qt_5_12_7_MinGW_64_bit-Release'
21:45:29: Process"D:\TTTTTTTTTTTTTTTTTTTTTTTTTTT\qt\Tools\mingw730_64\bin\mingw32-make.exe" ended normally.
21:45:29: Time has passed: 00:02.

我关注的是。

mingw32-make[1]: Nothing to be done for 'first'.

它是什么,它是做什么的?

但是,当我运行(伪)构建的应用程序时,我得到了。

21:25:57: Starting C:\Users\**\Desktop\**\2\BattleShips\build-B-Desktop_Qt_5_12_7_MinGW_64_bit-Release\release\B.exe ...
21:25:57: The process was ended forcefully.
21:25:57: C:\Users\**\Desktop\**\2\BattleShips\build-B-Desktop_Qt_5_12_7_MinGW_64_bit-Release\release\B.exe crashed.

当我试图从资源管理器中手动运行构建的应用程序时,我得到了典型的链接错误(就像使用了库的动态链接)

Qt5core.dll can not be found

和另一个关于缺少一些gcc库的问题。

我想是我的.pro文件有问题。下面是我的.pro文件。

static {
    CONFIG += static
    QT += core gui network widgets
    DEFINES += STATIC
    message("Static build.")
}
CONFIG +=  static -std=c++2a

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    battlefield.cpp \
    image.cpp \
    main.cpp \
    player.cpp \
    server.cpp \
    window.cpp

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

FORMS += \
    window.ui

HEADERS += \
    includes.h \
    player.h \
    window.h

Ide : windows 10 + qt 5.12.0 + mingw7.3.0 64 bit with qt.

有什么建议可以让我正确的构建和启动这个程序吗?

c++ qt mingw release qmake
1个回答
0
投票

2个问题:Qt文件需要在 "D:\\... "中。PATH 而Qt必须能够找到它的插件。

你可以启动一个命令提示符并运行这个。

SET PATH=<qt_path>\bin:$PATH
SET QT_PLUGIN_PATH=<qt_path>\plugins

在运行编译后的 .exe 从同一个命令提示符。

© www.soinside.com 2019 - 2024. All rights reserved.