Reputation: 33920
I use ssh to iphone, and can compile console apps on iphone using clang or gcc. But now how can I link against UIKit? Compiler finds headers and stuck at linking.
what args I should pass to clang? How can I check if I have the required static/shared libs? what exactly are the files to link against?
the example program:
#import <stdio.h>
#import <UIKit/UIView.h>
int main() {
UIView *U = [UIView alloc];
printf("OK\n");
return 0;
}
Here is the command line and error:
$ clang main.m
Undefined symbols:
"_OBJC_CLASS_$_UIView", referenced from:
__objc_classrefs__DATA@0 in main-2RgCk6.o
"_objc_msgSend", referenced from:
_main in main-2RgCk6.o
ld: symbol(s) not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
extra info:
$ uname -a
Darwin devphone-teki-iPhone 13.0.0 Darwin Kernel Version 13.0.0: Sun Dec 16 19:58:44 PST 2012; root:xnu-2107.7.55~11/RELEASE_ARM_S5L8940X iPhone4,1 arm N94AP Darwin
$ clang --version
clang version 3.1 (trunk 152547)
Target: arm-apple-darwin13.0.0
Thread model: posix
Upvotes: 0
Views: 517
Reputation: 33920
Answer my question after successful compilation.
You need to use apt to install clang gcc p7zip then find sdk 3
iphone_sdk_3.1.3_with_xcode_3.1.4__leopard__9m2809a.dmg
Extract to get
iPhoneSDK3_1_2.pkg
Then extract it again to -> ~/sdk
(You may need to use 7z many times to extract deeper), you will get this:
$ ls ~/sdk
Developer/ Entitlements.plist ResourceRules.plist SDKSettings.plist System/ usr/
Then compile like this
clang main.m -o main -isysroot ~/sdk/ \
-miphoneos-version-min=2 -L~/sdk/usr/lib -lobjc \
-framework UIKit \
-framework Foundation
Once you get 'main' copy it to your app folder and owerwrite previously installed app.
cp main /var/stash/Applications.Q6ABC7/myApp.app/myapp
kill myapp
Now you can click icon of your app and see it works.
Upvotes: 1