C++ C++;带有string类的程序在命中main()断点之前失败,请删除string变量,它将按预期工作

C++ C++;带有string类的程序在命中main()断点之前失败,请删除string变量,它将按预期工作,c++,g++,cygwin,stdstring,C++,G++,Cygwin,Stdstring,我的环境是 视窗10 Cygwin64 g++5.2.0 以下程序按预期工作(main执行时无错误,返回0) 最后,动态链接如下所示: $ gdb ./my_string GNU gdb (GDB) Cygwin 7.9.1-1 Copyright (C) 2015 Free Software Foundation, Inc. ... Type "apropos word" to search for commands related to "word"... Reading symbols

我的环境是

  • 视窗10
  • Cygwin64
  • g++5.2.0
以下程序按预期工作(main执行时无错误,返回0)

最后,动态链接如下所示:

$ gdb ./my_string
GNU gdb (GDB) Cygwin 7.9.1-1
Copyright (C) 2015 Free Software Foundation, Inc.
...
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./my_string...done.
(gdb) b main
Breakpoint 1 at 0x1004010fa: file my_string.cc, line 10.
(gdb) run
Starting program: /home/Admin/progs/c++/word_bubbles/my_string
[New Thread 107280.0x1a15c]
[New Thread 107280.0x1a2ac]
[New Thread 107280.0x1a050]
[New Thread 107280.0x1a3f4]
[Thread 107280.0x1a3f4 exited with code 3221225785]
[Thread 107280.0x1a2ac exited with code 3221225785]
[Thread 107280.0x1a050 exited with code 3221225785]
During startup program exited with code 0xc0000139.
(gdb)
$ ldd my_string
    ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x7ffef9820000)
    KERNEL32.DLL => /cygdrive/c/Windows/system32/KERNEL32.DLL  (0x7ffef9370000)
    KERNELBASE.dll => /cygdrive/c/Windows/system32/KERNELBASE.dll (0x7ffef6d10000)
我知道编译器的输出有点冗长,但我正试图提供诊断问题所需的一切

编辑1:根据建议,这里是strace输出:

$ strace ./my_string.exe
--- Process 105768 created
--- Process 105768 loaded C:\Windows\System32\ntdll.dll at 00007FFEF9820000
--- Process 105768 loaded C:\Windows\System32\kernel32.dll at 00007FFEF9370000
--- Process 105768 loaded C:\Windows\System32\KernelBase.dll at 00007FFEF6D10000
--- Process 105768 thread 107956 created
--- Process 105768 thread 56196 created
--- Process 105768 thread 92192 created
--- Process 105768 loaded E:\cygwin64\bin\cyggcc_s-seh-1.dll at 00000003F4260000
--- Process 105768 loaded E:\cygwin64\bin\cygstdc++-6.dll at 00000003EDF70000
--- Process 105768 loaded E:\cygwin64\bin\cygwin1.dll at 0000000180040000
--- Process 105768, exception c0000139 at 00007FFEF98B2F50
--- Process 105768 thread 92192 exited with status 0xc0000139
--- Process 105768 thread 105388 exited with status 0xc0000139
--- Process 105768 thread 56196 exited with status 0xc0000139
--- Process 105768 exited with status 0xc0000139
进程异常似乎在某个Windows DLL地址范围(ntdll.DLL)中

编辑2:使用strace,将弹出以下内容


我已经安装了Anaconda Python发行版,在成功的程序strace中,我看到了一些带有Anaconda路径的行,因此我临时重命名了Anaconda目录,以确保重新编译和重新运行不会找到Anaconda,但没有任何效果。

这是您的编译器,程序运行正常,检查:您的程序以错误代码0xc0000139结束,这意味着状态\入口点\未\找到。显然,DLL找不到或不匹配。尝试在dependency walker下运行您的程序(进程监视器也可以提供帮助),查看它在运行时尝试加载的DLL(动态加载的事实可能是您使用ldd看不到错误的原因)。Eran,我运行了strace并将输出信息添加到原始描述中。可能缺少的入口点应该解析为cygstdc++-6.dll。谢谢大家的帮助。尝试重新安装gcc。谢谢n.m。我可能会再次尝试重新安装,但我昨天这么做是为了解决另一个问题,我在重新安装时非常小心,以检查gcc包版本是否匹配
$ ldd my_string
    ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x7ffef9820000)
    KERNEL32.DLL => /cygdrive/c/Windows/system32/KERNEL32.DLL  (0x7ffef9370000)
    KERNELBASE.dll => /cygdrive/c/Windows/system32/KERNELBASE.dll (0x7ffef6d10000)
$ strace ./my_string.exe
--- Process 105768 created
--- Process 105768 loaded C:\Windows\System32\ntdll.dll at 00007FFEF9820000
--- Process 105768 loaded C:\Windows\System32\kernel32.dll at 00007FFEF9370000
--- Process 105768 loaded C:\Windows\System32\KernelBase.dll at 00007FFEF6D10000
--- Process 105768 thread 107956 created
--- Process 105768 thread 56196 created
--- Process 105768 thread 92192 created
--- Process 105768 loaded E:\cygwin64\bin\cyggcc_s-seh-1.dll at 00000003F4260000
--- Process 105768 loaded E:\cygwin64\bin\cygstdc++-6.dll at 00000003EDF70000
--- Process 105768 loaded E:\cygwin64\bin\cygwin1.dll at 0000000180040000
--- Process 105768, exception c0000139 at 00007FFEF98B2F50
--- Process 105768 thread 92192 exited with status 0xc0000139
--- Process 105768 thread 105388 exited with status 0xc0000139
--- Process 105768 thread 56196 exited with status 0xc0000139
--- Process 105768 exited with status 0xc0000139
my_string.exe entry point not found

The entry point

_ZNSt7__cxx1112basic_stringlcSt11char_traitslcESalcEEC1EPKcRKS3_ could
not be located in the dynamic link library.