gpt4 book ai didi

c++ - Qt应用程序启动崩溃

转载 作者:太空宇宙 更新时间:2023-11-04 06:01:13 27 4
gpt4 key购买 nike

我正在做一个更大(仍然很小)的游戏项目作为家庭作业。它基于Qt 4.8.6,完美运行在Windows 7 64位上。它也可以在 64 位 Linux 上编译,但在启动时崩溃。对于不同的堆栈跟踪,崩溃点似乎很常见,但我没有在网上找到我的案例,并且我不知道如何修复它。

我试过了

  • 重新编译了项目。重新编译Qt。
  • 在网络上进行了搜索。再次。再次。
  • 在 gdb 中来回走动(将使用调试符号重新编译 qt)
  • 用 strace 观看,最后一个 Action 正在加载 /usr/lib/libicudata.so.44

gdb 回溯:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000ecf720 in QResourceRoot::operator==(QResourceRoot const&) const ()
(gdb) bt
#0 0x0000000000ecf720 in QResourceRoot::operator==(QResourceRoot const&) const ()
#1 0x0000000000ecd175 in qRegisterResourceData (version=1, tree=0x10d8f60 "", name=0x10d8ee0 "", data=0x10d8320 "") at io/qresource.cpp:846
#2 0x0000000000bda227 in qInitResources_qmessagebox () at .rcc/debug-static/qrc_qmessagebox.cpp:257
#3 0x0000000000bda27a in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at .rcc/debug-static/qrc_qmessagebox.cpp:261
#4 0x0000000000bda2be in global constructors keyed to qrc_qmessagebox.cpp () at .rcc/debug-static/qrc_qmessagebox.cpp:270
#5 0x0000000000fee3e6 in __do_global_ctors_aux ()
#6 0x000000000040ee1b in _init ()
#7 0x0000000000000000 in ?? ()

(Qt 未使用“-debug”时的原始内容: http://pastebin.com/6GsKDM8d )

  • Application: public QApplication
  • 构造函数什么都不做,只是传递 argc , argv从此。
  • 我没有全局Q事物。我没有一般的全局事物,只有一些简单的常量。

程序编译(每种示例):

  • UIC:uic inc/ed/gomoku/ui/FEditProfile.ui -o inc/ed/gomoku/ui/FEditProfile.ui.h
  • 文档:moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I../thirdparty/qt/include inc/ed/gomoku/ui/FEditProfile.h -o inc/ed/gomoku/ui/FEditProfile.moc.cpp
  • cxx:g++ -DDEBUG -g -o inc/ed/gomoku/ui/FEditProfile.moc.o -c -fmessage-length=0 -fpermissive -Wall -Wextra -Wno-long-long -Wno-variadic-macros -Wno-unused-local-typedefs -MMD -MP -MF"inc/ed/gomoku/ui/FEditProfile.moc.d" -MT"inc/ed/gomoku/ui/FEditProfile.moc.d" -Iinc/ed -I../utils/inc/ed -I../ejson/inc/ed -I../thirdparty/boost -I../thirdparty/qt/include -c inc/ed/gomoku/ui/FEditProfile.moc.cpp
  • cxx:g++ -DDEBUG -g -o src/ed/gomoku/ui/FEditProfile.o -c -fmessage-length=0 -fpermissive -Wall -Wextra -Wno-long-long -Wno-variadic-macros -Wno-unused-local-typedefs -MMD -MP -MF"src/ed/gomoku/ui/FEditProfile.d" -MT"src/ed/gomoku/ui/FEditProfile.d" -Iinc/ed -I../utils/inc/ed -I../ejson/inc/ed -I../thirdparty/boost -I../thirdparty/qt/include -c src/ed/gomoku/ui/FEditProfile.cpp
  • 链接:g++ -DDEBUG -g -o gomoku_client gomoku_client.a ../ejson/ejson.a ../utils/utils.a ../thirdparty/boost/stage/lib/libboost_regex.a ../thirdparty/boost/stage/lib/libboost_date_time.a ../thirdparty/boost/stage/lib/libboost_filesystem.a ../thirdparty/boost/stage/lib/libboost_system.a ../thirdparty/boost/stage/lib/libboost_thread.a ../thirdparty/boost/stage/lib/libboost_chrono.a ../thirdparty/qt/lib_lin64/libQtGui.a ../thirdparty/qt/lib_lin64/libQtCore.a -lpthread -lz -ldl -lX11 -lXft -lXext -lglib-2.0 -lgthread-2.0 -lgobject-2.0 -lSM

ldd 输出:

    linux-vdso.so.1 =>  (0x00007fff91fff000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007f51ce520000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007f51ce309000)
libdl.so.2 => /lib/libdl.so.2 (0x00007f51ce104000)
libX11.so.6 => /usr/lib/libX11.so.6 (0x00007f51cddc9000)
libXft.so.2 => /usr/lib/libXft.so.2 (0x00007f51cdbb5000)
libXext.so.6 => /usr/lib/libXext.so.6 (0x00007f51cd9a2000)
libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0x00007f51cd6c6000)
libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x00007f51cd4c2000)
libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x00007f51cd27a000)
libSM.so.6 => /usr/lib/libSM.so.6 (0x00007f51cd072000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f51ccd5e000)
libm.so.6 => /lib/libm.so.6 (0x00007f51ccadb000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f51cc8c5000)
libc.so.6 => /lib/libc.so.6 (0x00007f51cc563000)
/lib64/ld-linux-x86-64.so.2 (0x00007f51ce75c000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x00007f51cc32d000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x00007f51cc0a5000)
libXrender.so.1 => /usr/lib/libXrender.so.1 (0x00007f51cbe9b000)
librt.so.1 => /lib/librt.so.1 (0x00007f51cbc92000)
libICE.so.6 => /usr/lib/libICE.so.6 (0x00007f51cba77000)
libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007f51cb85b000)
libpcre.so.3 => /lib/libpcre.so.3 (0x00007f51cb62a000)
libuuid.so.1 => /lib/libuuid.so.1 (0x00007f51cb426000)
libexpat.so.1 => /usr/lib/libexpat.so.1 (0x00007f51cb1fd000)
libXau.so.6 => /usr/lib/libXau.so.6 (0x00007f51caffa000)
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007f51cadf5000)

Qt 配置:./configure -prefix ~/local/qt -opensource -confirm-license -static -no-sql-sqlite -no-qt3support -no-xmlpatterns -no-multimedia -no-audio-backend -no-phonon -no-phonon-backend -no-svg -no-webkit -no-javascript-jit -no-script -no-scripttools -no-declarative -qt-zlib -qt-libpng -qt-libtiff -qt-libmng -qt-libjpeg -no-openssl -nomake demos -nomake examples -no-nis -no-cups -no-iconv -no-dbus -no-opengl

/proc/版本:Linux version 2.6.32-5-amd64 (Debian 2.6.32-48squeeze4) (dannf@debian.org) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Mon Sep 23 22:14:43 UTC 2013

最佳答案

如果我们使用的 qt include 目录不完全适合我们使用的库(.lib.a),则可能会发生神秘崩溃。应用程序可以在没有任何警告的情况下编译和链接,但很容易出现意外崩溃。

关于c++ - Qt应用程序启动崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23646718/

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