Wednesday, June 6, 2012

iPad iOS 5.1 “configure: error: connot run C compiled programs.”

I recently tried to compile a program in my iPad which runs iOS 5.1.1. Installing the gcc is quite straight forward and if you follow a slightly updated version of tootallnate’s guide you will easily get to the point of having gcc (get the iOS 5.0 sdk instead of 4.3 mainly). The problem is that Apple changed iOS 5 to run only signed apps and this renders most of the existing configure scripts useless.



Trying to compile vim you might get the following:
iPad:~/vim73 root# ./configure configure: creating cache auto/config.cache checking whether make sets $(MAKE)... yes checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... configure: error: in `/var/root/vim73/src': configure: error: cannot run C compiled programs.


Configure can’t run the test exe it compiles cause it doesn’t sign the app prior executing it.


In order to fix this, open the config.log file (in my case it was in src/auto) and locate the configure file’s line where you got the kill, for example mine was line 3098 seeing the following output:


configure:3096: ./conftest auto/configure: line 3098: 39952 Killed: 9 ./conftest$ac_cv_exeext


That line of code reads:


(eval "$ac_try") 2>&5


which is the execution of the executable created. So in order to fix this, add another command just above the testing code which reads something like:


eval "ldid -S ./conftest$ac_cv_exeext"


where ldid (apt-get install ldid) is the pseudo-codesign app that is available in the cydia sources that signs the produced executable (located at “./conftest$ac_cv_exeext”).


Hope this helps!


PS: I have also stumbled upon this forum where someone proposed to wrap gcc with a python script in order to automatically fix all the config files, but unfortunately didn’t work in my case.

1 comment:

Anonymous said...

This fix is so F**** sweet, thank you