Cannot compile on Mac without specifying -isysroot flag
Kyle Martin
martinky24@gmail.com
Mon Oct 1 23:51:00 GMT 2018
In follow up,
From a Mac (also Mojave) where g++ works, g++ -v returns:
$ g++ -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr
--with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.2)
Target: x86_64-apple-darwin18.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
On mine (which fails), I get:
$ g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.11.45.2)
Target: x86_64-apple-darwin18.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Does anyone perhaps have an understanding of what it takes to reset my installation to have the proper default directories?
Thanks!
Kyle
> On Oct 1, 2018, at 5:40 PM, Kyle Martin <martinky24@gmail.com> wrote:
>
> (!! if someone can help me sort this out I’ll Venmo you $10 !!)
>
> Hello,
>
> After upgrading to macOS Mojave I am no longer to compile basic C++ code “out of the box” on my 2018 MacBook Pro.
>
> In short, a “Hello world” program fails, which I am assuming the compiler cannot locate the “iostream” header. After some digging on StackOverflow I found that I can compile if and only if I set the following flag in my compilation call:
>
> -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
>
> So I guess my GCC/g++ installation is by default not looking there, but if I specify the .sdk directly it finds what it needs.
>
> What I cannot find is how to force my g++ calls to search in this directory for the default headers by default.
>
> I found https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html <https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html>, but it seemed to be specific for general flags I can set at runtime, not information on how to generally change the default path.
>
>
> Full details here:
> https://stackoverflow.com/questions/52581857/cant-compile-c-hello-world-with-include-after-upgrading-to-mojave <https://stackoverflow.com/questions/52581857/cant-compile-c-hello-world-with-include-after-upgrading-to-mojave>
>
> I’m a student still learning my way around the compiler, so sorry if any of my jargon was imprecise. Any pointers would be appreciated, as I feel as though I’ve exhausted what I can find on Google and the above StackOverflow post didn’t go anywhere.
>
> Appreciate it!
> Kyle
More information about the Gcc-help
mailing list