开发者

Link objective C library with C/ C++ Code base

We have a library with objective-c classes and exposed C APIs to use these classes. Now on iOS, i would like link it with c code base. How can i link this library statically with c code base.

Please sugge开发者_高级运维st.

I tried the following and giving the following error :

$gcc -static cApp.c -L. -lTestLib 
ld: library not found for -lcrt0.o
collect2: ld returned 1 exit status
$

Please help Thanks


The -static flag will prevent any dynamic linking, which in this case breaks the linking against the C runtime library. If TestLib is a static library then it should work if you just remove the -static flag.

$gcc cApp.c -L. -lTestLib 

Note that this will try to build a binary for the host operating system. You may want to set the appropriate SDK and architecture if you build for iOS.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜