Compiling multiple Objective-C files on the command line with clang -


hopefully simple question. i'm trying learn basic objective-c compiling command line, clang. understand xcode better solution complex projects , plan on moving soon, feel understand language better if can compile manually in terminal, , small introductory programming projects find less of hassle compile in terminal having start new project.

so question is: how compile objective-c program consists of multiple files (from command line)? (i'm trying fraction program chapter 7 of kochan's textbook, main.m , fraction.m file both #import "fraction.h", , fraction.h file imports foundation framework.) compile single file use like

clang -fobjc-arc main.m -o prog1 

but if type , want include files other main.m in project, errors including:

ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) 

if try add additional files command arguments, like

clang -fobjc-arc main.m fraction.h fraction.m -o prog1 

then get

clang: error: cannot specify -o when generating multiple output files 

and if remove -o argument like

clang -fobjc-arc main.m fraction.h fraction.m 

then giant pile of errors referring foundation framework, ending in "fatal error: many errors emitted, stopping now".

how do , make work? or need suck , use xcode more 1 file involved?

only implementation files (*.m) compiled, not interface/include files, should work:

clang -fobjc-arc main.m fraction.m -o prog1 

the strange error message "generating multiple output files" caused fact clang can compile header files "precompiled header files".


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -