How to resolve duplicate symbol link static library

Submitted by lepton on Fri, 05/20/2016 - 11:35


首先从静态库中解压 .o 文件

ar -x lib.a

nm查看符号表  找到重复的函数符号名

nm a.o


0000000000000000 T __Z4testv //c++

0000000000000000 T test //c


隐藏符号 相当于加 static

ld -r a.o -unexported_symbol  __Z4testv -o c.o; rm a.o; mv c.o a.o //mac 下可使用

objcopy --localize-symbol=_Z4testv a.o


ld -r a.o -alias __Z4testv test_c  -unexported_symbol  __Z4testv -o c.o //mac 下可使用

objcopy --redefine-sym _Z4testv=test_a a.o

如果其他 .o文件引用了这个函数 对每一个文件都要执行

find ./ -name "*.o" -exec objcopy --redefine-sym _Z4testv=test_a {} \;


c语言可以 函数改名变成foo_test
c++因为引入了很多系统函数 只能用上面的方法一个一个该

objcopy --prefix-symbols=foo_ a.o


ar crs lib.a *.o


uvabuzayua (not verified)

Sat, 01/18/2020 - 10:36

Magnesium aspect [URL= - generic tadalafil[/URL - [URL= - levitra online[/URL - [URL=… - generic kamagra soft online[/URL - [URL=… - propecia cost[/URL - [URL= - sobre orlistat[/URL - [URL= - finax lowest price[/URL - [URL= - gambling[/URL - [URL= - nolvadex[/URL - [URL= - doxycycline hyclate 100 mg[/URL - achieved butter, cialis without a doctor 20mg levitra how long kamagra soft price at walmart propecia canada xenical lowest price finax gamble online how to order nolvadex doxycycline hyclate 100 mg tablets close nails tadalafil 20mg… levitra online… buying kamagra soft online propecia canada xenical lowest price order finax online gambling buy nolvadex doxycycline doxycycline bloody propria.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.