0

I'm trying to compile GNU bash 4.3.30 on (and for) my iPad 2, iOS 8.4 using Clang, ld64, cctools, GNU make and the iOS 8.1 SDK. When processing libintl, cctools' ar "can't find or exec: /usr/bin/ranlib", causing make to exit with error 1.

$ make
(...)
rm -f libintl.a
ar cr libintl.a bindtextdom.o dcgettext.o dgettext.o gettext.o finddomain.o loadmsgcat.o localealias.o textdomain.o l10flist.o explodename.o dcigettext.o dcngettext.o dngettext.o ngettext.o plural.o plural-exp.o localcharset.o relocatable.o localename.o log.o osdep.o intl-compat.o
fatal error: ar: can't find or exec: /usr/bin/ranlib (No such file or directory)
ar: internal ranlib command failed
make[1]: *** [libintl.a] Error 1
make[1]: Leaving directory '/private/var/mobile/bash-4.3.30/lib/intl'
make: *** [lib/intl/libintl.a] Error 1

$ echo $CC
clang --sysroot /var/mobile/iPhoneOS8.1.sdk -v
$ clang --version
clang version 3.5.0 (trunk)
Target: armv7-apple-darwin-14.0.0
Thread model: posix
$ ld -v
@(#)PROGRAM:ld  PROJECT:ld64-
configured to support archs: i386 x86_64 armv4t armv5 armv6 armv7 armv7f armv7k armv8 arm64 arm64v8
$ which ranlib
$ ranlib
-sh: ranlib: command not found
$ find / -name ranlib
$

Apparently, my iPad has no ranlib. So, where can I find one? I've tried the ranlib.sh script from GNU binutils, which simply does ar s "$1", but then make tells me ar: no archive specified. Or is there any way to compile GNU bash 4.3.30 without it?

osvein
  • 625
  • 2
  • 10
  • 31
  • Did you ever get it to compile successfully? I want to do something similar, but for iOS 6. – Dan Jan 22 '16 at 17:23
  • @Dan no, I gave up rather quickly, but I don't remember what conclusions I drew. However, the `org.coolstar.cctools` package from the BigBoss repo seems to include ranlib. – osvein Jan 22 '16 at 18:39
  • Alright, thanks. I tried compiling 4.2 a year ago or so with no success either. – Dan Jan 23 '16 at 02:06

2 Answers2

1

ranlib creates an index for libraries. It is possible this isn't needed or Apple libraries are different than POSIX libraries.

So following a hint from https://developer.apple.com/library/ios/documentation/DeveloperTools/glibtool/libtool_3.html you can try creating /usr/bin/ranlib as such:

#!/bin/sh
ar cru $@

And of course chmod +x it. If $@ contains ranlib options such as -q, you'll need to modify the above to remove that.

To keep going in the face of errors add the --keep-going or -k option to make.

That may not work, so instead or in addition there is this is a big hack which might work. Every place in the Makefile that you see libintl.a, substitute bindtextdom.o dcgettext.o dgettext.o gettext.o finddomain.o loadmsgcat.o. And you may have to put in paths such as /private/var/mobile/bash-4.3.30/lib/intl/bindtextdom.o etc.

The last thing to do is just build binutils. That may be a bit tough though.

rocky
  • 7,226
  • 3
  • 33
  • 74
  • I know cctools doesn't provide any executable called ranlib, but I don't know if cctools provide ranlib functionality in some other manner (e.g. `ar s` like I think GNU binutils do). Also, I've read [here](http://sourceware.org/ml/binutils/2012-05/msg00404.html) that GNU binutils don't work well with arm-darwin binaries. – osvein Jul 07 '15 at 22:12
  • Thanks, that sounds like what I'm looking for! – osvein Jul 07 '15 at 22:17
  • Nope, `ar: illegal option combination for -q` :( – osvein Jul 08 '15 at 10:10
  • Where did `-q` come from? Was that in `$*`? if so, remove that from `$*`. – rocky Jul 08 '15 at 10:19
  • -q was in $*. I removed it, and got `ar: no archive members specified` (the same message I get when I do `ar s $*`). – osvein Jul 08 '15 at 11:54
  • What exactly was in $*? add "echo $0 $@" to the script before running "ar". – rocky Jul 08 '15 at 14:59
  • `/usr/bin/ranlib -q libintl.a`. My guess is that cctools, unlike GNU binutils, expect more arguments for `ar s`. `usage: (...) ar -q [-cTLsv] archive file ...` – osvein Jul 08 '15 at 16:09
  • See if Thomas's solution works. If so I'll edit down this. – rocky Jul 14 '15 at 10:40
0

The cctools package in Cydia is broken, but luckily ranlib is just a symlink to libtool, so

ln -s $(which libtool) /usr/bin/ranlib

should fix it.

Thomas
  • 3,074
  • 1
  • 25
  • 39