An error is reported when compiling with a low version of the glibc library? This method helps you solve

Glibc contains some main C libraries of linux, which are used to allocate memory, search directories, open and close files, read and write files, string processing, pattern matching, mathematical calculations, etc.

 

 

make tool

Note that since the make version of the AW server is 3.8.1, it is not compatible when compiling a higher version of glibc, so the make tool needs to be updated. If the server make version is higher, you do not need to update the make tool.

URL http://ftp.gnu.org/pub/gnu/make, download the latest version 4.3. After decompression, install the make tool. Enter the make-4.3 source code directory and execute the following command.

# prefix 后面路径为make工具安装路径,这里我们指定安装到out目录下。
./configure --prefix=${path}
make 
make install

The installation is complete, we see the make 4.3 version

glibc source code download

URL http://ftp.gnu.org/pub/gnu/glibc/, download the required glibc version, note that the gcc toolchain version and glibc version need to match.

As shown in the figure below, the source code of each version of the script env.sh and glibc is ready to be compiled.

env.sh is a script that integrates all compilation steps, and each instruction can be executed independently according to the specific situation.

Open the script env.sh script. The 4th line is the location of gcc, the 5th line is the location of the make tool (it can be removed without installing a higher version of make), the 7th line is the glibc version, the 12th line is the glibc source code path, and the 13th line is the glibc generated library file path, The 14th line is the storage path of the intermediate files generated by the glibc compilation process, and the 16th line is to modify the environment variables and use our own make and gcc tools. Lines 30-33 are used to compile glibc.

Among them, line 31 --host=arm-none-linux-gnueabihf, the value filled in by host must match gcc, otherwise it will cause a business trip.

Run the env.sh script

./env.sh

Pay attention to the information, we can see that when glibc generates the preparation environment, the gcc tool chain and make tool we specified have been used.


After the compilation is complete, we see the corresponding so library

Replace glibc, for example, when we test the demo, modify the Makefile and specify the path to our glibc version

Recompile, check the corresponding execution file, and see that the corresponding version of the glibc library has been used

strings main | grep glibc

version matching problem

1. gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabi version, glibc version below 2.29 can be compiled and passed

2. The gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf version is currently only compiled with glibc 2.33, and other versions need to be tested.

{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/6169614/blog/9771591