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 suggest.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.