zoukankan      html  css  js  c++  java
  • 添加静态库入动态库时,符号查找不到的问题

    编译静态库进入动态库时,有时会出现编译通过,调用时却出现symbol查找不到的问题。

    这是因为链接静态库时,只会将编译时用到的符号添加进动态库,有些符号是希望动态加载,在编译的时候并未显示调用。

    这时需要将静态库全部链接。

    1 -Wl,--whole-archive 
    2 -Wl,--start-group 
    3 -lopencv_core 
    4 -Wl,--end-group 
    5 -Wl,--no-whole-archive 

    -Wl,option

    Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas. You can use this syntax to pass an argument to the option. For example, -Wl,-Map,output.map passes -Map output.map to the linker. When using the GNU linker, you can also get the same effect with `-Wl,-Map=output.map'.

    即表明之后的命令是传递给linker的选项。

    --whole-archive 表明将所以object全部链接进来。

    --start-group和--end-group用于解决循环依赖问题,因此,组内的库可以多次搜索新的符号,并且您不需要像-llib1 -llib2 -llib1这样的丑陋的构造

    -( archives -) or --start-group archives --end-group

    The archives should be a list of archive files. They may be either explicit file names, or -l options.

    The specified archives are searched repeatedly until no new undefined references are created. Normally, an archive is searched only once in the order that it is specified on the command line. If a symbol in that archive is needed to resolve an undefined symbol referred to by an object in an archive that appears later on the command line, the linker would not be able to resolve that reference. By grouping the archives, they all be searched repeatedly until all possible references are resolved.

    Using this option has a significant performance cost. It is best to use it only when there are unavoidable circular references between two or more archives.

     
  • 相关阅读:
    线性表(List)
    LUA ipairs遍历的问题
    C#预编译的问题
    Resources与StreamingAssets文件夹的区别
    LUA表与函数的深入理解
    LUA 删除元素的问题
    SVN版本回退
    C# MemoryStream先写后读的奇怪现象
    LUA表 pairs, ipairs输出顺序问题
    LUA table.sort的问题,数组与表的区别
  • 原文地址:https://www.cnblogs.com/zl1991/p/9437192.html
Copyright © 2011-2022 走看看