table of Contents
Compile-time header file is not found
- Compiler flags -v, displays all the header file search path
- Acer is open
- Specifies whether the compiler flags -I path
- Header file plus #error "xxxx", if the header files are compiled to, it will error
Compile-time symbol can not be found
- Whether the source file / header files are compiled into a
- Whether the symbol is the extern
- With c ++ compiler, whether to raise the extern "C"
- Is there a macro is not open
- Whether there is a header file that contains cross
Compile-time libraries can not be found
- Link flags -v, displays all library search path
- Specifies whether the link flags -L path
- -L under the presence of the library path
- The default DLL search path / lib, / usr / lib, / usr / local / lib and so the presence of the library
- Whether the current tool chain and libraries inconsistent
Runtime library can not be found
Runtime library search path order
- Link, -Wl, -rpath = first_path: dynamic library search path specified second_path
- LD_LIBRARY_PATH environment variable specified dynamic library search path
- Specified in the configuration file /etc/ld.so.conf dynamic library search path
- The default DLL search path / lib, / usr / lib
Runtime library search path View
- ldd program_name (ldd is a shell script)
ldd ./exe_json
linux-vdso.so.1 => (0x00007ffdfd3ed000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2441ae6000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f24417dd000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2441413000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2441d03000)
- strace -e trace=open program_name
(Part of embedded linux system when compiling the firmware, did not open this feature)
strace -e trace=open ./exe_json
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
+++ exited with 0 +++
Different tool chains fit when symbol can not be found
- Chains of different tools with macro definitions of certain control symbols
eg:struct sockaddr_in结构体需要开启的宏
- linux PC: -D_GNU_SOURCE
- linux rk3308: -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE
Different tool chains compile the run error
- The size of the end
- 32-bit / 64-bit
- -O2 optimization errors (such as encryption error message mbedtls communication network), change -O0
reference
- ldd principle https://www.cnblogs.com/kelamoyujuzhen/p/9823272.html
- -rpath-link action parameter https://blog.csdn.net/q1302182594/article/details/42102961