clang++ Include File Search Question

I am running Catalina 10.15.7, Xcode 12.4, Command Line Tools 12.4

and I am trying to build Octave from source.

I am getting clang++ compiler errors because the compiler is bringing in 'math.h' from /usr/local/include instead of /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include.


In file included from libinterp/dldfcn/__delaunayn__.cc:54:

In file included from ./liboctave/array/dMatrix.h:31:

In file included from liboctave/numeric/DET.h:33:

In file included from liboctave/numeric/lo-mappers.h:35:

./liboctave/util/lo-ieee.h:78:53: error: expected unqualified-id

inline int __lo_ieee_isnan (double x) { return std::isnan (x); }

                                                    ^

/usr/local/include/math.h:165:5: note: expanded from macro 'isnan'

( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))  



$ ls -l /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk

total 0

lrwxr-xr-x  1 root        wheel   14 Feb 27 10:28 MacOSX.sdk -> MacOSX11.1.sdk

drwxr-xr-x@ 6 davidlaxer  staff  192 Sep 27 07:55 MacOSX10.11.sdk

drwxr-xr-x  8 root        wheel  256 Feb 27 10:36 MacOSX10.15.sdk

drwxr-xr-x  7 root        wheel  224 Feb 27 10:33 MacOSX11.1.sdk


$ xcode-select -p

/Library/Developer/CommandLineTools


$ xcrun -show-sdk-path


/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk


export CFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk"

export CCFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk"

export CXXFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk"

export CPPFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk"

export CXXFLAGS="-std=c++11 -stdlib=libc++ $CXXFLAGS"

export CPPFLAGS="-std=c++11 -stdlib=libc++ $CPPFLAGS" 

export CC=/usr/bin/clang

export CXX=/usr/bin/clang++

export CCLD=/usr/bin/clang

export CXXLD=/usr/bin/clang++

export DEVELOPER_DIR=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk



Any idea why clang++ is accessing /usr/local/include before /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include?

I tried various clang++ flags (e.g. -nostdinc++), but it broke ./configure.

MacBook Pro 15″, macOS 10.15

Posted on Feb 27, 2021 11:51 AM

Reply

Similar questions

12 replies

Mar 3, 2021 11:55 AM in response to davidlaxer

davidlaxer wrote:

./configure CXXFLAGS="-std=c++17 -stdlib=libc++ -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/Users/davidlaxer/SuiteSparse/include -I/opt/local/libexec/qt5/include -I/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/include"

"Ah! QT!" the Mac developer gasped, as he pulled the bloody dagger from his chest, collapsing to the ground.

Mar 3, 2021 7:48 AM in response to etresoft

/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk has iconv.h but no dynamic libraries (.dyld) for iconv.

This is causing the compiler to use the include file from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk but

the library from '/opt/local/include'.

How is this supposed to work?


$ xcrun -show-sdk-path


/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk

$ find /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr -name '*iconv*' -ls

12984623222       24 -r--r--r--    1 root             wheel                8295 Jun  5  2020 /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/iconv.h


12984624073        0 lrwxr-xr-x    1 root             wheel                  14 Feb 27 10:25 /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib/libiconv.2.4.0.tbd -> libiconv.2.tbd


12984624702        8 -r--r--r--    1 root             wheel                 759 Jul  9  2020 /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib/libiconv.2.tbd


12984624795        0 lrwxr-xr-x    1 root             wheel                  18 Feb 27 10:25 /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib/libiconv.tbd -> libiconv.2.4.0.tbd

Mar 3, 2021 9:55 AM in response to davidlaxer

Those "tbd" files are the dylib stub files. The operating system will load the appropriate library at runtime. As of Big Sur, the actual library files are never used. Everything is loaded directly from cache.


This is causing the compiler to use the include file from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk but the library from '/opt/local/include'.

In your previous reply you said that changing the C++ version fixed the problem. Is this not true? You also said you were having trouble due to include files in /usr/local/include. Now you are adding /opt/local/include too? This won't end well...

Mar 3, 2021 11:18 AM in response to etresoft

>> In your previous reply you said that changing the C++ version fixed the problem

Changing to std=c++17 resolved the standard library compilation issues but I still have the 'iconv' issue.


E.g.


Undefined symbols for architecture x86_64:

"_libiconv_close", referenced from:

_octave_iconv_close_wrapper in libwrappers.a(libwrappers_la-iconv-wrappers.o)

"_libiconv_open", referenced from:

_octave_iconv_open_wrapper in libwrappers.a(libwrappers_la-iconv-wrappers.o)

ld: symbol(s) not found for architecture x86_64



Mar 3, 2021 12:03 PM in response to etresoft

etresoft wrote:

"Ah! QT!" the Mac developer gasped, as he pulled the bloody dagger from his chest, collapsing to the ground.

Translation, you will have to ask Octave and/or QT support for this. I'm outta here!


<sigh> I'll try to be nice.


I don't know what to tell you. QT is just a train wreck. People seem to think it is some kind of quick-n-easy cross-platform tool. But even the smallest QT "Hello world" app seems to need truly expert-level knowledge of:

1) the project in question

2) any build system being used

3) compilers

4) UNIX

5) macOS

6) Apple digital signatures and notarization

7) dynamic libraries

8) Mac-specific complications such as the Mac runtime environment, frameworks, Xcode, etc.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

clang++ Include File Search Question

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.