macでコマンドラインでxcodeコンパイルとbuild2012/06/03 08:01

揮発環境確認
$ xcodebuild -version
Xcode 4.3.2
Build version 4E2002
$ xcodebuild -showsdks
Mac OS X SDKs:
Mac OS X 10.6 -sdk macosx10.6
Mac OS X 10.7 -sdk macosx10.7

iOS SDKs:
iOS 5.1 -sdk iphoneos5.1

iOS Simulator SDKs:
Simulator - iOS 4.3 -sdk iphonesimulator4.3
Simulator - iOS 5.0 -sdk iphonesimulator5.0
Simulator - iOS 5.1 -sdk iphonesimulator5.1

xcode3.2の環境は switchしないとダメみたい

//--- source code sample1.mm start ---
#import <Foundation/Foundation.h>

void (^f)(id) = ^(id x) {
NSLog(@"Hello World %@", x);
};

int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
f(@"hoge");
[pool release];
return 0;
}
//--- source code end ---

コンパイル build

$clang -framework Foundation sample1.mm -o sample1

実行
.$/sample12012-06-03 08:07:04.079 sample1[4384:707] Hello World hoge

ヘルプ
clang --help
OVERVIEW: clang "gcc-compatible" driver

USAGE: clang [options] <inputs>

OPTIONS:
-### Print the commands to run for this compilation
--analyze Run the static analyzer
--help Display available options
--relocatable-pch Build a relocatable precompiled header
--serialize-diagnostics <value>
Serialize compiler diagnostics to a file
-E Only run the preprocessor
-ObjC++ Treat source input files as Objective-C++ inputs
-ObjC Treat source input files as Objective-C inputs
-Qunused-arguments Don't emit warning for unused driver arguments
-S Only run preprocess and compilation steps
-Wa,<arg> Pass the comma separated arguments in <arg> to the assembler
-Wl,<arg> Pass the comma separated arguments in <arg> to the linker
-Wp,<arg> Pass the comma separated arguments in <arg> to the preprocessor
-Xanalyzer <arg> Pass <arg> to the static analyzer
-Xassembler <arg> Pass <arg> to the assembler
-Xclang <arg> Pass <arg> to the clang compiler
-Xlinker <arg> Pass <arg> to the linker
-Xpreprocessor <arg> Pass <arg> to the preprocessor
-arcmt-migrate-emit-errors
Emit ARC errors even if the migrator can fix them
-arcmt-migrate-report-output <value>
Output path for the plist report
-c Only run preprocess, compile, and assemble steps
-emit-ast Emit Clang AST files for source inputs
-emit-llvm Use the LLVM representation for assembler and object files
-fcatch-undefined-behavior
Generate runtime checks for undefined behavior.
-flimit-debug-info Limit debug information produced to reduce size of debug binary
-fno-limit-debug-info Do not limit debug information produced to reduce size of debug binary
-ftrap-function=<value> Issue call to specified function rather than a trap instruction
-o <file> Write output to <file>
-pipe Use pipes between commands, when possible
-print-file-name=<file> Print the full library path of <file>
-print-libgcc-file-name Print the library path for "libgcc.a"
-print-prog-name=<name> Print the full program path of <name>
-print-search-dirs Print the paths used for finding libraries and programs
-rewrite-objc Rewrite Objective-C source to C++
-save-temps Save intermediate compilation results
-time Time individual commands
-verify Verify output using a verifier.
-v Show commands to run and use verbose output
-working-directory <value>
Resolve file paths relative to the specified directory
-x <language> Treat subsequent input files as having type <language>

コメント

コメントをどうぞ

※メールアドレスとURLの入力は必須ではありません。 入力されたメールアドレスは記事に反映されず、ブログの管理者のみが参照できます。

※なお、送られたコメントはブログの管理者が確認するまで公開されません。

※投稿には管理者が設定した質問に答える必要があります。

名前:
メールアドレス:
URL:
次の質問に答えてください:
下記の文字を入力して下さい(半角スペースあります)
Hoge desu

コメント:

トラックバック