Hey guys

Hey guys,

I am playing with libc bridging on Android and iOS. I was able to use it on Android as follow:
const LibC = '/system/lib/libc.so';

function gethostname(name: MarshaledAString; len: NativeUInt): Int32; cdecl; external LibC;

However I don't know where is the libc library on iPhone devices and simulator. The LibC constant only works for Android now as I don't know what I put on it for iOS, where ia stored the libc on iOS? Can you help me?

Thanks in advance :D

Comments

  1. AFAIR there is no "libc" under iOS, but their own set of libc-like low-level APIs.

    ReplyDelete
  2. A. Bouchez Yeah :D But I don`t know where it is to reference on LibC variable :(

    ReplyDelete
  3. Allen Bauer Can you help me? Many thanks :D What is the path for libc on iOS? :D

    ReplyDelete
  4. Horácio Filho There is NO libc library, as I wrote. So you have to access directly the dedicated API, as Alexey Kazantsev wrote above.

    ReplyDelete
  5. Horácio Filho Also note that last time I've checked, Android does not have a the whole glibc, but only a dedicated subset, named "Bionic" - https://en.wikipedia.org/wiki/Bionic_(software) - so some libc entries may not be there.

    ReplyDelete
  6. A. Bouchez​ My idea is rewrote the POSIX Unistd library, I want to know how to play with native APIs :D just for studies :D, but I don't know what I should write after external keyword for iOS in order to access the native gesthostname function.

    ReplyDelete
  7. function gethostname(name : pointer; namelen : size_t) : integer; cdecl; external '/usr/lib/libc.dylib' name 'gethostname';

    ReplyDelete
  8. Thanks a lot Alexey Kazantsev :D There is a bit of problem on this function declaration, this call will work only on iOS 32-bit and 64-bit compilers, the iPhone Simulator compiler requires using the underscore prefix before the function name, you have to check the compiler directive UNDERSCOREIMPORTNAME to do that :D

    ReplyDelete
  9. Alexey Kazantsev I came with this version function gethostname(name: PUTF8Char; len: NativeUInt): Int32; cdecl; external LibCPath name Prefix + 'gethostname'; :D

    ReplyDelete

Post a Comment