SDKROOT path for latest SDK
Asked Answered
A

4

29

I am using Xcode to build an old code and specify SDKROOT=/Developer/SDKs/MacOSX"${HOST_VERSION}".sdk/

I want to specify SDKROOT for latest SDK that comes pre-installed (?) on the system. e.g. I am on 10.8 already and I want to specify SDKROOT with -syslibroot, but there is no such SDK in /Developer/SDKs/. Should i just ignore syslibroot altogether if SDK_VERSION == HOST_VERSION?

Athabaska answered 20/12, 2012 at 3:13 Comment(0)
C
47

Newer Xcode versions have the SDKs inside the Xcode.app bundle, e.g.

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk

You get the list of installed SDKs together with their path by running

xcodebuild -sdk -version

from the command line.

If you have installed the "Command Line Tools" (Xcode Preferences -> Downloads -> Components) then compiling without "-syslibroot" should be equivalent to compiling against the latest SDK.

See the help to the "Command Line Tools" package:

Downloading this package will install copies of the core command line tools and system headers into system folders, including the LLVM compiler, linker, and build tools.

Clincher answered 20/12, 2012 at 8:38 Comment(0)
K
17

As stated in another stackoverflow question:

xcrun --sdk macosx --show-sdk-path
Kuehl answered 25/10, 2017 at 16:52 Comment(0)
C
6

With xcodebuild -version -sdk macosx10.7 Path you can get the Path to the OS X 10.7 SDK. You may replace 10.7 by ${SDK_VERSION} or ${HOST_VERSION} depending on your needs. I know of no command to obtain the version of OS X, which could be used to obtain the Path to the SDK matching the version of OS X currently running.

Note: for xcodebuild to work, the user must have configured xcode-select properly, for example xcode-select -switch /Application/Xcode.app.

Coherence answered 30/8, 2013 at 9:52 Comment(0)
C
0

CommandLineTools was outdated, reinstalling Command Line Tools fixed the issue:

xcode-select --install
Consist answered 14/10, 2019 at 13:52 Comment(1)
I don't particularly understand why this was downvoted. More often than not xcode-select --install proves to be the correct answer.Gabbie

© 2022 - 2024 — McMap. All rights reserved.