Tag Archives: undefined reference to `pow‘

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