当我可以从终端编译时在Linux和Eclipse中编译

时间:2015-03-04 17:51:53

标签: c++ linux eclipse debugging makefile

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

./configure
make

既然我有程序的源代码,我的目标是调试它(在C ++代码和东西上设置断点)。由于我第一次使用Linux,因此我下载了eclipse以获得直观的GUI。但是,当我导入项目时,我似乎无法编译它。包括错误无处不在,无论我尝试多少都无法解决。

当我可以在终端中进行编辑时,如何在eclipse中编译它?另外,还有另一种调试程序的方法吗?

非常感谢!

1 个答案:

答案 0 :(得分: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中删除了所有警告标志,不确定它是否有所作为。你应该恢复这些如果你要针对这个版本进行开发)
  4. GNUmakefile

    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)