Eclipse/CDT 无法调试具有链接依赖项的应用程序 - 程序退出,代码为 0xc0000135

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18326989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:06:06  来源:igfitidea点击:

Eclipse/CDT cannot debug application with linked dependencies - program exits with code 0xc0000135

c++eclipsedlleclipse-cdt

提问by Jared Lindsey

I have two C++ projects in Eclipse, "amp" and "amp_auditions"

我在 Eclipse 中有两个 C++ 项目,“amp”和“amp_auditions”

The first creates a library, C:\Users\Jared\EclipseWorkspace\amp\Debug\libamp.dll

首先创建一个库, C:\Users\Jared\EclipseWorkspace\amp\Debug\libamp.dll

The second, a test program ('C:\Users\Jared\EclipseWorkspace\amp_auditions'), depends on the first, and has the directory C:\Users\Jared\EclipseWorkspace\amp\Debuglisted under Project Properties > Library Dependencies

第二个是测试程序 ( 'C:\Users\Jared\EclipseWorkspace\amp_auditions'),依赖于第一个,并且C:\Users\Jared\EclipseWorkspace\amp\Debug在项目属性 > 库依赖项下列出了目录

To use the amp library I created, I thought all I needed to do was link the library file and include the headers, but apparently it isn't that simple.

要使用我创建的 amp 库,我认为我需要做的就是链接库文件并包含标题,但显然它并没有那么简单。

Everything compiles, but when I go to debug, the application immediately terminates. The GDB trace tells me:

一切都会编译,但是当我去调试时,应用程序立即终止。GDB 跟踪告诉我:

488,262 19^error,msg="During startup program exited with code 0xc0000135."

If I run the test program directly in a terminal, it complains about missing dependencies. If I place the libamp.dllfile in the C:\Users\Jared\EclipseWorkspace\amp_auditionsdirectory, everything works just fine. This tells me it is an issue where the debugger can't find libamp.dll

如果我直接在终端中运行测试程序,它会抱怨缺少依赖项。 如果我将libamp.dll文件放在C:\Users\Jared\EclipseWorkspace\amp_auditions目录中,一切正常。这告诉我这是调试器找不到的问题libamp.dll

What did I miss? Why won't my test program run within the Eclipse debug perspective?

我错过了什么?为什么我的测试程序不能在 Eclipse 调试透视图中运行?

gcc -v

gcc -v

COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.6.2 (GCC) 

gdb trace:

gdb 跟踪:

487,988 2-environment-cd C:/Users/Jared/EclipseWorkspace/amp_auditions
487,991 2^done
487,991 (gdb) 
487,991 3-gdb-set breakpoint pending on
487,991 3^done
487,991 (gdb) 
487,992 4-gdb-set detach-on-fork on
487,992 4^done
487,992 (gdb) 
487,992 5-enable-pretty-printing
487,992 5^done
487,992 (gdb) 
487,992 6-gdb-set python print-stack none
487,993 6^done
487,993 (gdb) 
487,993 7-gdb-set print object on
488,003 7^done
488,003 (gdb) 
488,004 8-gdb-set print sevenbit-strings on
488,005 8^done
488,005 (gdb) 
488,005 9-gdb-set host-charset UTF-8
488,005 9^done
488,006 (gdb) 
488,006 10-gdb-set target-charset WINDOWS-1252
488,016 10^done
488,016 (gdb) 
488,017 11-gdb-set target-wide-charset UTF-16
488,017 11^done
488,017 (gdb) 
488,017 12source .gdbinit
488,027 &"source .gdbinit\n"
488,027 &".gdbinit: No such file or directory.\n"
488,027 12^error,msg=".gdbinit: No such file or directory."
488,027 (gdb) 
488,028 13-gdb-set target-async off
488,028 13^done
488,028 (gdb) 
488,029 14-gdb-set auto-solib-add on
488,029 14^done
488,029 (gdb) 
488,029 15-gdb-set solib-search-path C:\Users\Jared\EclipseWorkspace\amp\Debug
488,029 15^done
488,029 (gdb) 
488,031 16-file-exec-and-symbols --thread-group i1 C:/Users/Jared/EclipseWorkspace/amp_auditions/Deb\
ug/amp_auditions.exe
488,065 16^done
488,065 (gdb) 
488,067 17-break-insert --thread-group i1 -t -f main
488,134 18-list-thread-groups
488,167 17^done,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x004013ad",func="ma\
in()",file="..\src\amp_auditions.cpp",fullname="C:\Users\Jared\EclipseWorkspace\amp_auditions\
\src\amp_auditions.cpp",line="14",times="0",original-location="main"}
488,167 (gdb) 
488,167 18^done,groups=[{id="i1",type="process",executable="C:\Users\Jared\EclipseWorkspace\amp_\
auditions\Debug\amp_auditions.exe"}]
488,168 (gdb) 
488,172 19-exec-run --thread-group i1
488,205 =thread-group-started,id="i1",pid="3220"
488,205 =thread-created,id="1",group-id="i1"
488,205 ~"[New Thread 3220.0xa8c]\n"
488,205 19^running
488,205 *running,thread-id="all"
488,205 (gdb) 
488,206 20-list-thread-groups --available
488,260 =thread-exited,id="1",group-id="i1"
488,261 =thread-group-exited,id="i1"
488,262 19^error,msg="During startup program exited with code 0xc0000135."
488,262 (gdb) 
488,262 20^error,msg="Can not fetch data now."
488,263 (gdb) 
488,270 21-gdb-exit
488,293 21^exit

回答by Jorgen G Valley

My understanding of the problem is that this has nothing to do with eclipse. A .dll is linked dynamically, at runtime. This means that your running application must find the library (.dll) in the system path or in the running executable folder.

我对问题的理解是,这与eclipse无关。.dll 在运行时动态链接。这意味着您正在运行的应用程序必须在系统路径或正在运行的可执行文件夹中找到库 (.dll)。

A solution to your immediate problem would be to add the directory where the .dll is compiled to your Windows path variable.

您当前问题的解决方案是将编译 .dll 的目录添加到您的 Windows 路径变量中。

回答by Codeguard

You build your test application and DLL to different folders. There's no way EXE will know where DLL is. The typical solutions are:

您将测试应用程序和 DLL 构建到不同的文件夹。EXE 不可能知道 DLL 在哪里。典型的解决方案是:

  1. Build to the same folder, such as 'Bin'
  2. Copy the DLL as a post-build step.
  1. 构建到同一个文件夹,例如'Bin'
  2. 复制 DLL 作为构建后步骤。

回答by Alex

Another option is to add the paths to your dlls to the LD_LIBRARY_PATH
In the debug configuration in Eclipse (Right click your project, debug as, debug configuration) click on the Environment tab. Click the New... button and put

另一种选择是将 dll 的路径添加到LD_LIBRARY_PATH
在 Eclipse 的调试配置中(右键单击您的项目,调试为,调试配置)单击环境选项卡。单击新建...按钮并放置

Name:  LD_LIBRARY_PATH
Value: put the absolute path to your dll here. Separate multiple paths with a ";"

On Mac OS X its called DYLD_LIBRARY_PATH
On Linux based system you can define the variable temporarily in the same command like this:

在 Mac OS X 上,它被称为DYLD_LIBRARY_PATH
在基于 Linux 的系统上,您可以在相同的命令中临时定义变量,如下所示:

bash$ LD_LIBRARY_PATH=/path/to/libs ./executable

I'm not sure how to do this in windows.
Double check to see if the path to your libraries is correct!

我不确定如何在 Windows 中执行此操作。
仔细检查库的路径是否正确!

回答by Manuel

Another easy option is to configure the Run->Debug Configurations in eclipse: There, expand the C/C++ Application, select your Debug application, then in the right-hand "Debugger" tab click on the "Shared Libraries" tab and add the paths to your shared libraries.

另一个简单的选择是在 eclipse 中配置 Run->Debug Configurations:在那里,展开 C/C++ 应用程序,选择您的调试应用程序,然后在右侧的“调试器”选项卡中单击“共享库”选项卡并添加共享库的路径。

回答by Makato

For other looking for a solution:

对于其他寻找解决方案的人:

The run configuration allows you set a PATH. Here you can add your own settings without modifying the system environment (yet). I tend to forget this at times and run into the exact same problem you described. Adding the path here solves the issue.

运行配置允许您设置 PATH。在这里你可以在不修改系统环境的情况下添加你自己的设置(还)。我有时会忘记这一点,并遇到您描述的完全相同的问题。在此处添加路径可以解决问题。