tencent cloud

TencentOS Server

Using the GCC Compiler Toolchain

Download
Focus Mode
Font Size
Last updated: 2026-10-19 17:22:50
AI-Translated

Introduction to GCC

GCC stands for GNU Compiler Collection. It is a compiler software developed by the GNU Project. Initially supporting C/C++, it later expanded to support ObjectC, Go, Fortran, and other languages, evolving into a compiler suite. It is now primarily supported and maintained by the FSF.

GCC Selection and Maintenance Policy on TencentOS Server 4

TencentOS Server 4 ships with GCC 12.x by default. Throughout the full maintenance cycle of GCC 12 in the upstream community, this system will promptly follow up on minor version updates until this distribution is no longer maintained.

GCC Components on TencentOS Server 4

Component
X86_64
Aarch64
Description
gcc
Supported
Supported
C compiler of GCC
gcc-c++
Supported
Supported
C++ compiler of GCC, known as g++ in some distributions
gccgo
Supported
Supported
Golang compiler of GCC
gfortran
Supported
Supported
Fortran compiler of GCC
gnat
Supported
Supported
Ada compiler of GCC
gcc-objc
Supported
Supported
ObjectC compiler of GCC
gcc-objc++
Supported
Supported
ObjectC++ compiler of GCC
gcc-gdc
Supported
Supported
D language compiler of GCC
gcc-gm2
Not supported.
Not supported
M2 language compiler of GCC, introduced in GCC 13, not supported in TencentOS Server 4

Installation

# gcc
dnf install gcc
# gcc-c++
dnf install gcc-c++
# gccgo
dnf install gccgo
# gfortran
dnf install gfortran
# libtsan
dnf install libtsan
# Developing with tsan
dnf install libtsan-devel
# For other components, see 1.2 and install them by component name.
# Note that libgomp does not provide a devel package.

Introduction to GCC

Introduction to the GCC Workflow - A C Language Example

Take a C program source file named helloworld.c as an example:
#include <stdio.h>
int main() {
printf("hello,world!\\n");
return 0;
}
The process from installation to execution of the source code is as follows:
# Install the C compiler
dnf install gcc
# Compile into a binary
gcc -o helloworld helloworld.c
# Execute
./helloworld

More Features of GCC Program Execution

The compiler's processing of source code can be divided into four stages: Preprocessing, Compilation, Assembly, and Linking. Next, let's try using gcc to process the source code step by step.
Take a file named hellooc.cpp as an example:
#include <iostream>
using namespace std;

char* hellooc(char* oc) {
cout << "hello, " << oc << "!" << endl;
return oc;
}
You need to install the corresponding GCC compiler development environment.
# Install the GCC C++ compiler, C++ development libraries, and runtime
dnf install gcc-c++ libstdc++-devel

Preprocessing

First, perform preprocessing:
g++ -E -o hellooc.i hellooc.cpp
# The result is too long to be displayed in this document. Run the command yourself to view it.
less hellooc.i

Compilation

Then perform compilation (in the narrow sense), which produces assembly code:
g++ -S -o hellooc.s -fPIC hellooc.i
# The result is too long to be displayed in this document. Run the following command to view it.
less hellooc.s

Assembly Compilation

Continue with assembly compilation, which produces an unlinked object file:
g++ -c -o hellooc.o hellooc.s

Link

Finally, perform linking, which produces a linked library:
# Dynamic Linking
g++ -o hellooc.so -shared -lstdc++ hellooc.o

# Static Linking
ar rcs hellooc.a hellooc.o
The results are as follows:
hellooc.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=92a45a52fc17fa866d765841e159d57271e767b1, not stripped

hellooc.a: current ar archive

More References

This document is intended only to help developers understand the GCC component support status, installation methods, and simple usage examples on this system. For more information about GCC and development resources, see the official GCC documentation and third-party materials.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback