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