GDB No symbol "XXXXX" in current context

Source: Internet
Author: User

These days, when porting projects under Windows to CentOS, there are three reasons for GCC compilation:

1, gcc vs, the C + + standard to follow more stringent, some non-conforming to the standard of writing in VS can be, but under the GCC error. For example, when declaring a member function of Class A in a header file, GCC cannot carry a::, or Initialize FStream, the first parameter under GCC must be a const char *, not a string, etc.

2, because the CentOS existing gcc4.4.7 version is too low, some c++11 in the usage does not support;

3, also because the GCC version is too low, several open source projects of the static library can not be compiled.

1th, 22 is OK to solve, but for the 3rd can not greatly change people's open source project, so update GCC to 4.8.1, compiled through, generated the executable file. But the pit daddy thing happened, when debugging with GDB, always error no symbol "XXXXX" in the current context.

Repeatedly checking the cmake inside sets the-G option, which shows that GCC compiles a symbol table, but why does GDB always say it can't find the symbol? Baidu, csdn not an answer useful, finally found on the stackoverflow reason: After the GCC upgrade, GDB did not upgrade, the new version of GCC produced by the symbol table of the low version of GDB does not know, so the symbol is not found.

There are two solutions:

1, update gdb;

2,GCC-4.8 defaults to the Using DWARF4 (gcc.gnu.org/gcc-4.8/changes.html), but GDB was too old to understand that. Build -gdwarf-2 with, it'll work!

That is, compile-time -gdwarf-2 Change-G to.


Reference: Http://stackoverflow.com/questions/18407563/gcc-doesnt-produce-line-number-information-even-with-g-option

GDB No symbol "XXXXX" in current context

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.