objective c keyworkd

Submitted by lepton on Mon, 10/10/2016 - 16:29


@protocol @required @optional @end
@interface @public @package @protected @private @property @end
@implementation @synthesize @dynamic @end
@throw @try @catch @finally
@synchronized @autoreleasepool
@selector @encode

c++ build flag cause the stl function symbol different

Submitted by lepton on Tue, 05/24/2016 - 12:43


export CXXFLAGS="-std=c++11 -stdlib=libc++"
export LDFLAGS="-stdlib=libc++"


link to libc++ or libstdc++

the stl function symbol in object file are different in mac with xcode 7

when use std::vector as a argument

the argument symbol is St6vectorIiSaIi linking to libstdc++

the other is St3__16vectorIiNS6_9allocatorIi

this will cause linking errors

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文件引用了这个函数 对每一个文件都要执行