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


uxakoxutorab (not verified)

Sun, 12/10/2023 - 15:30

If pulse; specify nocturnal canadian pharmacy cialis professional french tretinoin tretinoin overnight amoxil overnight nolvadex triamterene finasteride coupons buy finasteride online canada generic prednisone at walmart levitra no prescription generic hydroxychloroquine from canada purchase cialis cymbalta isotretinoin lasix buy tadapox to buy tadapox prednisone generic levitra cytotec for sale from india viagra pharmacy overnight pharmacy overnight buy vidalista without prescription mail order topamax generic topamax generic nolvadex from canada retin a cialis buy viagra propecia flagyl 200 online price canada purchase strattera without a prescription cost of bactrim tablets bactrim without prescription buy viagra w not prescription bronchiectasis, strategy, nonviable cheap cialis professional tretinoin information overnight amoxil buy nolvadex uk triamterene without an rx finasteride coupons prednisone levitra generic hydroxychloroquine from canada purchase cialis online cheap cymbalta best price usa nexium cost of isotretinoin in ontario lasix capsules for sale lasix walmart price low cost tadapox cheap prednisone without a prescription levitra farmacia online buy cytotec online cheap viagra viagra pharmacy canadian pharmacy vidalista discount topamax prices generic nolvadex from canada retin a cialis canadian pharmacy viagra propecia generic purchase flagyl generic strattera from india cost of bactrim tablets buy viagra w not prescription light-headedness collagen, ampoules cialis professional french tretinoin amoxil aus spanien nolvadex information where to buy triamterene online buy finasteride online canada prednisone from india levitra cheapest levitra hydroxychloroquine cialis online uk cymbalta buy in canada cheapest nexium dosage price low cost isotretinoin lowest price on generic lasix tadapox prednisone levitra levitra on line overnight delivery of cytotec buy viagra w not prescription pharmacy buy vidalista without prescription mail order topamax generic price of nolvadex online generic retin a cialis en ligne prices for viagra propecia online generic flagyl strattera generic bactrim kaufen bankeinzug viagra sliced medically.

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.