Tag Archives: gcc

GCC refers to math. H header file, and there are some errors such as undefined reference to ` POW ‘when compiling

The - LM option must be added to the GCC command line when using the library functions declared in math. H because the mathematical functions are located in libm. So library files (these library files are usually located in the /lib directory), - LM option tells the compiler, The mathematical functions used in our program should be found in this library file. Most of the library functions used in this book (such as printf ) are located in libc. So library files. When using the library functions in libc. So , you don’t need to add the - LC option when compiling. Of course, adding it is not wrong, because this option is the default option of GCC

C standard is mainly composed of two parts, one describes C syntax, the other describes C standard library. C standard library defines a set of standard header files, each of which contains some related functions, variables, type declarations and macro definitions. In order to support c language on a platform, it is necessary to implement not only c compiler but also c standard library. Only in this way can the implementation meet the C standard. For example, there are only C compilers and no complete C standard library in many SCM c language development tools

The most widely used C function library on Linux platform is glibc , including the implementation of C standard library. Almost all C programs call glibc library functions, so glibc is the basis of C program running on Linux platform glibc provides a set of header files and a set of library files, the most basic and most commonly used C standard library functions and system functions. In libc. So library files, almost all C programs run on libc. So , and some C programs for mathematical calculation rely on libm. So , We will see that multithreaded C programs rely on libpthread. So . In the future, when I say libc , I specifically refer to the library file libc. So , while when I say glibc I refer to all the library files provided by glibc

glibc is not the only basic C function library on Linux platform. Some people are developing other C function libraries, such as uclibc for embedded systems

Linux: apt get install build essential and Yum groupinstall “development tools”

Ubuntu’s apt install build essential

Function: to configure the Debian system compilation environment is to download and install the dependencies/packages that support the compilation of Debian packages, such as GCC.

Direct execution

#apt install build-essential

You can view log/var/log/apt after execution/ history.log , see the following.

Start-Date: 2019-06-08  07:54:24
Commandline: apt install build-essential
Requested-By: satou (1000)
Install: libmpc3:amd64 (1.1.0-1, automatic), libgcc-7-dev:amd64 (7.4.0-1ubuntu1~18.04, automatic), libmpx2:amd64 (8.3.0-6ubuntu1~18.04, automatic), linux-libc-dev:amd64 (4.15.0-51.55, automatic), libfakeroot:amd64 (1.22-2ubuntu1, automatic), libc6-dev:amd64 (2.27-3ubuntu1, automatic), cpp-7:amd64 (7.4.0-1ubuntu1~18.04, automatic), libalgorithm-diff-perl:amd64 (1.19.03-1, automatic), libalgorithm-merge-perl:amd64 (0.08-3, automatic), binutils:amd64 (2.30-21ubuntu1~18.04.1, automatic), cpp:amd64 (4:7.4.0-1ubuntu2.2, automatic), libitm1:amd64 (8.3.0-6ubuntu1~18.04, automatic), g++:amd64 (4:7.4.0-1ubuntu2.2, automatic), gcc-7-base:amd64 (7.4.0-1ubuntu1~18.04, automatic), gcc:amd64 (4:7.4.0-1ubuntu2.2, automatic), libcilkrts5:amd64 (7.4.0-1ubuntu1~18.04, automatic), libasan4:amd64 (7.4.0-1ubuntu1~18.04, automatic), libquadmath0:amd64 (8.3.0-6ubuntu1~18.04, automatic), libisl19:amd64 (0.19-1, automatic), build-essential:amd64 (12.4ubuntu1), libfile-fcntllock-perl:amd64 (0.22-3build2, automatic), binutils-x86-64-linux-gnu:amd64 (2.30-21ubuntu1~18.04.1, automatic), libstdc++-7-dev:amd64 (7.4.0-1ubuntu1~18.04, automatic), libtsan0:amd64 (8.3.0-6ubuntu1~18.04, automatic), libubsan0:amd64 (7.4.0-1ubuntu1~18.04, automatic), g++-7:amd64 (7.4.0-1ubuntu1~18.04, automatic), make:amd64 (4.1-9.1ubuntu1, automatic), fakeroot:amd64 (1.22-2ubuntu1, automatic), gcc-7:amd64 (7.4.0-1ubuntu1~18.04, automatic), liblsan0:amd64 (8.3.0-6ubuntu1~18.04, automatic), libgomp1:amd64 (8.3.0-6ubuntu1~18.04, automatic), manpages-dev:amd64 (4.15-1, automatic), binutils-common:amd64 (2.30-21ubuntu1~18.04.1, automatic), libc-dev-bin:amd64 (2.27-3ubuntu1, automatic), libbinutils:amd64 (2.30-21ubuntu1~18.04.1, automatic), libatomic1:amd64 (8.3.0-6ubuntu1~18.04, automatic), libcc1-0:amd64 (8.3.0-6ubuntu1~18.04, automatic), libdpkg-perl:amd64 (1.19.0.5ubuntu2.1, automatic), libalgorithm-diff-xs-perl:amd64 (0.04-5, automatic), dpkg-dev:amd64 (1.19.0.5ubuntu2.1, automatic)
Upgrade: gcc-8-base:amd64 (8.2.0-1ubuntu2~18.04, 8.3.0-6ubuntu1~18.04), libgcc1:amd64 (1:8.2.0-1ubuntu2~18.04, 1:8.3.0-6ubuntu1~18.04), libstdc++6:amd64 (8.2.0-1ubuntu2~18.04, 8.3.0-6ubuntu1~18.04)
End-Date: 2019-06-08  07:55:01

Note: (1) execute apt get update or apt update to update the package index before running, otherwise it may fail. (2) It is suggested to use apt instead of apt get

CentOS’s Yum - y groupinstall "development tools"

Function: to configure the compilation environment of CentOS is to download and install the package/dependency that enables CentOS to compile the source code package on the platform

You can use the command Yum grouplist to check which groups there are. Development tools is in available groups.

[root@localhost ~]# yum grouplist
Loaded plugins: fastestmirror, langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
Available Environment Groups:
   Minimal Install
   Compute Node
   Infrastructure Server
   File and Print Server
   Basic Web Server
   Virtualization Host
   Server with GUI
   GNOME Desktop
   KDE Plasma Workspaces
   Development and Creative Workstation
Available Groups:
   Compatibility Libraries
   Console Internet Tools
   <span style="color: red;"&><Development Tools</span&>
   Graphical Administration Tools
   Legacy UNIX Compatibility
   Scientific Support
   Security Tools
   Smart Card Support
   System Administration Tools
   System Management
Done

Before executing Yum groupinstall "development tools" , execute Yum clean all to clear Yum cache and force Yum to read some configuration files again

[root@localghost ~]# yum clean all
Loaded plugins: fastestmirror, priorities, remove-with-leaves
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@localghost ~]#

List of dependency packages included in the content tools

bison
byacc
cscope
ctags
cvs
diffstat
doxygen
flex
gcc
gcc-c++
gcc-gfortran
gettext
git
indent
intltool
libtool
patch
patchutils
rcs
redhat-rpm-config
rpm-build
subversion
swig
systemtap

Perform the demo

[root@localghost ~]# yum groupinstall "Development tools"


Install      86 Package(s)
Upgrade       0 Package(s)

Total download size: 77 M
Installed size: 234 M
Is this ok [y/N]:

Enter y to confirm the installation and N to cancel. Or Yum - y groupinstall "development tools" confirm in advance.

If you encounter the following error no packages in any requested group available to install or update , you need to configure the data source

cd /etc/yum.repos.d
sudo wget http://public-yum.oracle.com/public-yum-el5.repo
cd /etc/pki/rpm-gpg/
sudo wget https://public-yum.oracle.com/RPM-GPG-KEY-oracle-el5

Reference article

https://support.eapps.com/index.php?/Knowledgebase/Article/View/438/55/user -guide—installing-the-centos-development-tools-gcc-flex-etc

Expand

Lamp one click installation – in fact, with docker container technology, I feel that lamp (Linux + Apache + MySQL/MariaDB/percona + PHP) production environment is unnecessary