【问题标题】:Compiling in Linux&Eclipse when I can compile from terminal当我可以从终端编译时在 Linux&Eclipse 中编译
【发布时间】:2015-05-05 20:27:04
【问题描述】:

所以我终于能够下载旧版本的 webkit 并使用经典在终端中编译(修复 100 个错误后):

./configure
make

现在我有了程序的源代码,我的目标是调试它(在 C++ 代码和其他东西上设置断点)。因为我在这里第一次使用 Linux,所以我下载了 eclipse 以获得直观的 GUI。但是,当我导入项目时,我似乎无法编译它。包含错误无处不在,无论我如何尝试都无法解决它们。

当我可以在终端中编译时,如何在 Eclipse 中编译它?另外,有没有其他方法可以调试程序?

非常感谢!

【问题讨论】:

  • 您是否创建了“使用现有代码的 Makefile 项目”?如果有一个工作的makefile,这对我总是有用的。
  • 另一种方法是使用 gdb gnu.org/software/gdb
  • @MikeSeymour 不,我没有,我在网上找到了从源目录创建一个空项目的说明。我现在会搜索这些说明,谢谢!
  • @RobKielty 我可以运行 webkitgtk 可执行文件并以某种方式导入源吗?我认为 gdb 应该需要源 调试符号,我不知道如何使用终端在 Linux 中生成调试符号。可悲的是,我是 Visual Studio 的人。
  • 符号生成在编译时完成,因此构建过程可能会启用/禁用符号生成。

标签: c++ linux eclipse debugging makefile


【解决方案1】:

好的,所以我设法编译和链接代码,以便可以将其加载到带有符号调试信息的 gdb 中,如下所示:

  1. 我下载并解压了http://webkitgtk.org/releases/webkitgtk-2.0.4.tar.xz
  2. 我运行了 ./configure 并手动完成了 apt-get install(或在 ICU 下载和编译的情况下)所有必需的依赖项。
  3. 然后我对GNUmakefile 进行了以下修改,添加了-ggdb 对每个可变的global_cppflags global_cflagsglobal_cxxflags (为了加快构建速度,我从 cppflags 中删除了所有警告标志,不确定它有什么不同。如果你要这样做,你可能应该恢复这些针对此构建进行开发)

GNUmake 文件

global_cppflags := -ggdb -fno-exceptions -DBUILDING_CAIRO__ -DBUILDING_GTK__ \
         $(am__append_1) $(am__append_2)
#global_cppflags := -Wall -W -Wcast-align -Wchar-subscripts \
#       -Wreturn-type -Wformat -Wformat-security -Wno-format-y2k \
#       -Wundef -Wmissing-format-attribute -Wpointer-arith \
#       -Wwrite-strings -Wno-unused-parameter -Wno-parentheses \
#       -fno-exceptions -DBUILDING_CAIRO__ -DBUILDING_GTK__ \
#       $(am__append_1) $(am__append_2)
global_cflags := -ggdb
global_cxxflags := -ggdb -fno-rtti

然后为了测试调试符号是否包含在编译器和链接器输出中,我按如下方式运行 gdb

~/dev/webkitgtk-2.0.4$ gdb ./Programs/MiniBrowser -d ./Tools/MiniBrowser/gtk/ 
GNU gdb (Ubuntu 7.8-1ubuntu4) 7.8.0.20141001-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./Programs/MiniBrowser...done.
(gdb) l
188                                                         "WebKitSettings writable properties for default WebKitWebView",
189                                                         "WebKitSettings properties",
190                                                         webkitSettings,
191                                                         NULL);
192     g_option_group_add_entries(webSettingsGroup, optionEntries);
193     g_free(optionEntries);
194 
195     /* Option context takes ownership of the group. */
196     g_option_context_add_group(context, webSettingsGroup);
197 
(gdb) l
198     return TRUE;
199 }
200 
201 int main(int argc, char *argv[])
202 {
203     gtk_init(&argc, &argv);
204 
205     GOptionContext *context = g_option_context_new(NULL);
206     g_option_context_add_main_entries(context, commandLineOptions, 0);
207     g_option_context_add_group(context, gtk_get_option_group(TRUE));
(gdb) 

【讨论】:

  • 稍后我会看看如何在 Eclipse 中运行它,在那里进行调试会很方便。
  • 我不敢相信你做了这一切!!!我不能感谢你,真的。我会在 14 小时后接受你的回答,这样我就可以给你奖金
  • 这很有趣,我喜欢这样做?我已经下载了 c/c++ 的 Eclipse,并且会弄清楚让调试器在其中工作。应该是可行的。
  • 现在不让我给你赏金,显然我要等24小时,我要试试这个,谢谢!
  • 酷让我知道你过得怎么样。
猜你喜欢
  • 2017-10-02
  • 1970-01-01
  • 2014-03-01
  • 2012-02-05
  • 1970-01-01
  • 2015-01-09
  • 1970-01-01
  • 2013-03-14
  • 1970-01-01
相关资源
最近更新 更多