How to Compile and Package C/C++ Applications on Kunpeng: From Hello World to MySQL

This tutorial walks through setting up a Kunpeng development environment, building a simple Hello World program, creating a cross‑platform CMake project, and compiling, installing, and packaging MySQL 5.7 as RPM/DEB packages for CentOS 7 and Ubuntu 18.04.

Huawei Cloud Developer Alliance
Huawei Cloud Developer Alliance
Huawei Cloud Developer Alliance
How to Compile and Package C/C++ Applications on Kunpeng: From Hello World to MySQL

Overview – The guide explains how to prepare a Kunpeng (ARM) Linux environment, compile C/C++ programs, use CMake for cross‑platform builds, and create distributable packages for MySQL 5.7.

Hello World on Kunpeng

1. Log into the Kunpeng development environment. 2. Configure the software repository. 3. Install the C/C++ compiler. 4. Create main.c with a classic hello‑world source. 5. Compile with gcc and run the executable. 6. Add a standard Makefile to the project directory. 7. Build and test using make.

Standard Cross‑Platform CMake Project

Because compilers differ across platforms, CMake is used to generate appropriate Makefiles automatically. A CMakeLists.txt file is placed at the project root, and a temporary build directory is created. Running cmake generates the Makefile, after which make compiles the project.

Q: Why use a temporary directory? A: CMake lacks a clean mechanism; a temporary directory isolates generated files, allowing easy removal after a successful build.

Building MySQL 5.7 on Kunpeng

MySQL 5.7, a widely used C/C++ open‑source database, is compiled using CMake. The steps include:

Download the source package from Huawei Cloud mirrors.

Extract the archive.

Activate GCC 7.3 (the default GCC 4.8.5 on CentOS 7 has bugs that prevent a successful MySQL build).

Create a temporary build directory.

Run cmake to generate build files.

Compile with make and install (default install path unless overridden).

To distribute the software efficiently, RPM packages are created using rpmbuild. After building, the binaries reside in /root/rpmbuild/RPMS/aarch64/ and can be deployed across multiple Kunpeng instances.

For Ubuntu 18.04, the process is similar but produces DEB packages. After installing dependencies and extracting the source, the dpkg‑buildpackage command creates binary .deb files, which are then installed and configured.

Finally, the MySQL service is started, and users can log in with the initial password.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CLinuxmysqlCMakeDebianRPMKunpeng
Huawei Cloud Developer Alliance
Written by

Huawei Cloud Developer Alliance

The Huawei Cloud Developer Alliance creates a tech sharing platform for developers and partners, gathering Huawei Cloud product knowledge, event updates, expert talks, and more. Together we continuously innovate to build the cloud foundation of an intelligent world.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.