1

Since I updated to Mavericks my C app, compiled in my machine with clang, cannot be executed in Lion machines (yep, there are some people who have not updated). It throws

Segmentation fault: 11 error

I've read about stdlib option in this thread but it seems it only applies to clang++ and not to plain clang. Is there a similar option for clang? I've searched for --stdlib=libstdc in google but all results are for --stdlib=libstdc++

Community
  • 1
  • 1
hithwen
  • 2,154
  • 28
  • 46

2 Answers2

3

To compile an app for OS X 10.8 (Lion), you have to set the "Deployment Target". The corresponding command line option for clang is

-mmacosx-version-min=10.8

You might also want to set the SDK to 10.8, to avoid that any library functions are used that are available only in 10.9:

-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
0

I'm not sure the intent of the question, but Lion is actually 10.7, Mountain Lion is 10.8. Obviously, you wouldn't want to set the deployment target to 10.8, if you were targeting Lion (10.7). Both the previous comments and answer are conflicting in that regard.

*Note: I can't comment on them, as I don't have enough rep!

Ben Brian
  • 220
  • 3
  • 6