GCC with-gxx-include-dir is set to iOS 11.4 simulator I'm trying to compile https://github.com/zeromq/libzmq which requires me to run autoconf and then ./configure. It was working a few days ago, but now this happens: 

checking for a BSD-compatible install... /usr/local/bin/ginstall -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/local/bin/gmkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '502' is supported by ustar format... yes
checking whether GID '20' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking whether make supports nested variables... (cached) yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/Users/rajiv/libzmq/libzmq-4.2.5':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details


config.log shows:

configure:4489: checking whether we are cross compiling
configure:4497: gcc -o conftest    conftest.c  &gt;&amp;5
configure:4501: $? = 0
configure:4508: ./conftest
dyld: mach-o, but built for simulator (not macOS)
./configure: line 4510: 98877 Abort trap: 6           ./conftest$ac_cv_exeext
configure:4512: $? = 134


After searching GitHub for a while it seems like something might be wrong with GCC:

$ gcc -v

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/c++/4.2.1

Apple LLVM version 9.1.0 (clang-902.0.39.2)

Target: x86_64-apple-darwin17.7.0

Thread model: posix

InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin


It seems like it's trying to include from the iOS 11.4 SDK. How can I change it back to the correct path and how did this change happen? The only things I can think of are that I installed an update for the Xcode Command Line Tools and I may have updated autoconf with Homebrew
I was seeing a similar issue.

$ gcc -v
    Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/c++/4.2.1


In my case, that configuration resulted in includes like #include &lt;stdlib.h&gt; referencing the iOS/iPhone simulator platform libraries rather than the macOS libraries. This resulted in my getting errors about the wrong architecture being used when compiling.

The only viable solution I found was to uninstall Xcode (deleting the app from /Applications) and uninstall the command line tools. That and a reboot seemed to resolve this issue in my case.