Question

I have a library compiled into a .a file, linked against my application. (iphone, developing with Xcode)

Everything seems to be fine, linking seems to succeed, but when I run the program it crashes. The point of crash is at a memcmp() call in the statically linked library. The debugger shows all kind of stuff called with "dyld" in their names, so it seems that for whatever reason it can not resolve memcmp, starts looking for dynamic libraries, then fails.

AFAIK memcmp is in libc, so should not be a problem. (tried also passing -lc to the linker, and it did not help, just as I expected)

So how it is supposed to work? Why can't a statically linked library use anything from libc? How should I compile it?

Thank you

Was it helpful?

Solution 2

Perhaps someone will find it useful if I share what the problem was:

The library was not compiled for the same OS version as the main program, so it was expecting a different libc than what it found when running.

OTHER TIPS

libc is apparently dynamically linked on your platform. A matching version cannot be found at runtime to satisfy the dependency generated at link time.

I can't explain how this would happen other than filesystem corruption or calling chroot before the dynamic linking happens (which would seem unlikely).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top