10

I've been searching for quite some time, and I can't seem to find out how to change the compiler on the latest Xcode. I am not sure what it is set at currently, but I'd like to change it to GCC if possible. Right now my homework example will not recognize ptrace.h, so I think it might have to do with the chosen compiler.

Cœur
  • 37,241
  • 25
  • 195
  • 267
user1765804
  • 161
  • 2
  • 3
  • 10
  • You can change the compiler by selecting the target and selecting "Build Rules", finding the entry for the language and changing it. There is also the issue of GCC libraries that may need to be added. But GCC is not provided by Apple anymore, you will have to get the compiler. Perhaps you need to just use the command-line with GCC and not Xcode. – zaph Aug 29 '15 at 15:24
  • I cannot find build rules. – user1765804 Aug 29 '15 at 15:26
  • Look at the heading: General, Capabilities, Resource Tags, Info, Build Settings, Build Phases, **Build Rules**. – zaph Aug 29 '15 at 15:27
  • 1
    Bear with me here, but I do not see any of that, and General is not part of the Heading. – user1765804 Aug 29 '15 at 15:31
  • 3
    Ok, I found it, but LLVM is the only option it seems. Can I add other compilers? – user1765804 Aug 29 '15 at 15:41
  • Have you installed GCC? – zaph Aug 29 '15 at 15:46
  • Yeah I just installed GCC via homebrew and I switched over to it in the Build Options. The problem remains.. ptrace.h is still not found. Is it possible that it will only work on Linux (Ubuntu), or does ptrace also work on Mac? – user1765804 Aug 29 '15 at 16:16
  • It should work on the Mac, OS X *is* unix – but not linux. There may be a library you need to add to the project. But that is a different question, ask one about ptrace on OS X. – zaph Aug 29 '15 at 16:20

2 Answers2

4

Screenshot of Build Rules:

enter image description here

You can add a rule for C++, click the "+" to the right of "Custom".

zaph
  • 111,848
  • 21
  • 189
  • 228
4

Select the project in the browser, then navigate to...

XCode

dangerousdave
  • 6,331
  • 8
  • 45
  • 62