【问题标题】:Error when starting an application compiled with static linking of libraries in release mode在发布模式下启动使用库的静态链接编译的应用程序时出错
【发布时间】:2020-05-23 18:35:08
【问题描述】:

在调试模式下编译时,我的应用程序的启动和运行是可能的并且是成功的。此外,发布模式下的构建不会出现任何错误。

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 文件有问题。 就是这样:

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 随qt提供。

对如何正确构建和启动此应用程序有任何建议吗?

【问题讨论】:

    标签: c++ qt mingw release qmake


    【解决方案1】:

    两件事:Qt 文件需要在PATH 中,并且 Qt 必须能够找到它的插件。

    您可以启动命令提示符并运行以下命令:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-08
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多