GCC gdb under Mac OS

Source: Internet
Author: User
Tags posix

For a long time did not write C, today and wife adults to do a bit of Microsoft's online programming problems. Found that forget a lot.

Because there is a run-time error, so want to debug with GDB, found that there is no gdb, then use homebrew installation, the result of installation error. The reason why I discovered the mistake later was that I couldn't find gcc!. But I have been using GCC to compile the program Ah, curious Strange!

These two days VPN is unstable, only Baidu, finally found the reason:

Starting with Mac OS 10.9, GCC is no longer installed when XCODE5 is installed, and GCC in the system is actually an alias.

$ gcc-vconfigured with:--prefix=/applications/xcode.app/contents/developer/usr--with-gxx-include-dir=/ Applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.11.sdk/usr/include /c++/4.2.1apple LLVM version 7.0.0 (clang-700.0.72) target:x86_64-apple-darwin14.5.0thread model:posix$ clang-vapple LLVM version 7.0.0 (clang-700.0.72) Target:x86_64-apple-darwin14.5.0thread Model:posix

You can see that GCC is actually clang, and the clang corresponding debugging tool is LLDB. But since you gave Clang the name GCC, you can not be a good person to do to Lldb also an alias?

I built a symbol link in the bottom of the/usr/bin, and then I can use gdb conveniently.

By the way also see the next CLANG,LLVM and GCC relations, interested you can also go to search for clang and GCC's pros and cons, now it seems, for the C language support, clang should be an absolute advantage (of course not refers to the market share, but the user experience).


Clang:a C language family frontend for LLVM

The goal of the Clang project is to create a new C, C + +, Objective C and Objective C + + front-end for the LLVM compiler.

That is to say, Clang is a compiler's front-end, mainly responsible for grammar, lexical analysis and generate LLVM understandable code passed to LLVM to compile.


The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. Despite its name, LLVM have little to does with traditional virtual machines, though it does provide helpful libraries that C An is used to build them. The name "LLVM" itself is a acronym; It's the full name of the project.

LLVM began as a, project at the University of Illinois, with the goal of providing a modern, ssa-based compilation Strategy capable of supporting both static and dynamic compilation of arbitrary programming languages. Since then, LLVM have grown to being an umbrella project consisting of a number of subprojects, many of which is being used I n production by a wide variety of commercial and open source projects as well as being widely used in academic. Code in the LLVM project is licensed under the "UIUC" Bsd-style license.

LLVM is the main part of compiling and generating machine code.


The GNU Compiler Collection includes front ends for C, C + +, objective-c, Fortran, Java, Ada, and Go, as well as libraries For these languages (libstdc++, LIBGCJ,...). GCC is originally written as the compiler for THEGNU operating system.

In fact, GCC is not a software, but a set of software, full name GNU Compiler Collection. Compared to clang and LLVM, will also be divided into the front end, back end, recall the compiler principle, GCC will actually call the CPP first preprocessing, which is equivalent to the work done by clang, and then call CC1 and LD to compile and link, which is equivalent to the work of LLVM.

Here is an article that explains the history of CLANG/LLVM, the cooperation and contradictions between the fruit company and GCC:

Gcc,llvm,clang author Shao

As you can see from this article, their composition is not absolute, and GCC can also be used with LLVM.

Reference documents:

1,clang Official website:


2,LLVM Official website:


3,GCC Official website:


GCC gdb under Mac OS

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.