Question

So I have downloaded LLVM+Clang and set up the iOS SDK(7.0) on my iPhone. When I try to compile a test project called testProj, which is located at /testProj with this lines:

xcrun -sdk iphoneos clang

clang -v -ObjC -arch armv7s -mios-version-min=7.0 -isysroot/private/var/iPhoneOS7.0.sdk /testProj/testProj/main.m

I get this error:

clang: error: unable to execute command: posix_spawn failed: No such file or directory

It compiles main.m including the UIKit.framework reference perfectly and I seriously don't get what this error means. Is anyone understanding what I'm doing wrong respectively what I have forgotten here?

Thanks in advance

Was it helpful?

Solution

The clang-llvm package only contains the compiler and the optimizer. It does not contain the linker (ld) and, as far as I know, it doesn't contain the assembler (as) either.

You have to install these utilities, of which the most recent version (still a 2009 build, though...) can be found in Cydia or it can be downloaded from Saurik's repository: odcctools_286-8_iphoneos-arm.deb


Here are some more tips I'd like to share in order to resolve some common errors:

  1. After installing these tools, you still have to make some modifications. In particular, you have to create symlinks (from -> to):
$(SYSROOT)/usr/lib/libgcc_s.dylib -> libgcc.dylib
                libSystem.B.dylib -> libSystem.dylib
                  libobjc.A.dylib -> libobjc.dylib

(perhaps some further messing with the C++ standard library is necessary in order to get C++ compilation working, I haven't yet tried it.)

  1. After having done all this, you will be able to compile normal executables. However, if you are willing to make MobileSubstate tweaks (so you are compiling a dynamic library using the -dynamiclib flag), you will run into an error where the linker isn't able to find a symbol defined bundle1.o. The solution of this problem is to explicitly link the $(SYSROOT)/usr/lib/bundle1.o object file along with the other object files.

  2. I don't know which version/build on the on-device toolchain you have, but I have experienced a bug in my installation (I no longer remember where I've got from the package). I think there's a problem with the code generator of the clang/LLVM compiler, since if I am compiling with optimizations enabled, any non-trivial program will segfault. (And it's not that I write faulty code, since I have tried to compile and run highly reputed, well-tested libraries and programs, and those throw a segmentation fault as well...) So if you happen to run this faulty version of the compiler, then stay far away from optimizations. (And if you don't, then please let me know where you have found a better one :P)

OTHER TIPS

Try CppCode ios app - http://www.cppcode.info. It's IDE & Compiler that runs on iOS. No jb required, no internet required

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