编译、链接与库

Posted by shensunbo on July 11, 2024
  1. 链接顺序
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
     This is because the linker resolves symbols in the order that the libraries are listed on the command line. If a library is listed before the library it depends on, the linker will not be able to resolve the symbols, resulting in an error.
    
     So, in the example I gave earlier:
    
     A depends on B
     B depends on C
     The correct linking order would actually be:
    
     A
     B
     C
    
  2. 查看依赖的库 ```
    1. on target platform ldd
    2. not on target platform objdump -x | grep NEEDED readelf -d | grep NEEDED nm -D | grep NEEDED elfdump -d | grep NEEDED ``` 3.恢复默认的交叉编译选项 `unset LD_LIBRARY_PATH`