MacOS – stored C “object” and “executable” files in Xcode

developmentmacosterminalxcode

Platform:
OS X: Yosemite 10.10.4; Xcode: v6.4 (6E35b); MacbookPro 15" Retina (mid-2015).

Fact:
As C compiler and linker (upon standard) create .o and executable file(s)

Questions:

  1. Where (please provide path, or tell where I can configure by myself one) are those files stored by Xcode?
  2. Is this executable portable such that it can be run on Linux and Windows?
  3. Does Xcode gives same results (for obj and executable) as if I perform compilation manually in MacOS terminal?
  4. Is it possible in Xcode separately compile and separately link? If yes – please describe how?
  5. What compiler (type and version) exactly Xcode uses to compile?
  6. In general, regarding C and Java languages especially, how common is it for programmers who do not develop only for OS X or iOS to use Xcode?

Best Answer

  1. The files are stored in the project directory; in Xcode, find the file you'd like to see where is, right-click it, and choose "Show in Finder".
  2. Nope. You'll have to recompile for other platforms, and possibly change code to be more portable. (That last, of course, depends on what libraries you use.)
  3. Probably. Xcode may set some compiler flags you wouldn't in the terminal. Look in your project settings for these.
  4. I would expect so, but I do not know how.
  5. Clang from the LLVM project. Apple used to use gcc.

This is from my Yosemite (10.10.4) Mac with Xcode 6.4:

$ clang --version
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.4.0
Thread model: posix

Amusingly, gcc also is actually clang:

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.4.0
Thread model: posix
  1. If you want to develop native Mac or iOS apps, you pretty much have to use Xcode. Java apps are not native, and you cannot write Java code in Xcode. (One used to be able to write Java in Xcode back before OS X 10.4, before the Cocoa-Java bridge was deprecated.)