Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
7744 Discussions

Using classic 2021.5.0 20211109 on macOS with command line tools

JamesBurgess
Beginner
421 Views

Hi,

 I just wondering if it is possible to use classic icpc with just Apple's Command Line Tools installed? Seems to be that icpc doesn't quite get its include search path right. So if we have a very simple one line c++ file:

#include <stdio.h>

and we try and compile that with icpc with Apple's command line tools we get an error because the Apple C++ version of <stdio.h> is found correctly but that file uses #include_next <stdio.h> to find the C version (on macOS that'd be in the SDK) which is not on the search path:

 --> icpc -c stdio.cpp 
In file included from stdio.cpp(1):
/Library/Developer/CommandLineTools/usr/bin/../../usr/include/c++/v1/stdio.h(107): catastrophic error: cannot open source file "stdio.h"
  #include_next <stdio.h>
                         ^

compilation aborted for stdio.cpp (code 4)

  using -I$SDKDIR isn't a simple option here because that'll get put at the front of the search path and #include_next needs it to be after the C++ one. I guess I could use two -I flags, first for the C++ header and then the  C version but I'm hoping there is a simpler technique. I looked into using CPATH that I know classic also puts into the search path but that's also too early.

Here's the actual search path I end up with on such a mac:

 --> icpc -c -H -v stdio.cpp 
  ...
#include "..." search starts here:
#include <...> search starts here:
 /opt/intel/oneapi/tbb/2021.5.0/env/../include
 /opt/intel/oneapi/dnnl/2022.0.0/cpu_iomp/lib
 /opt/intel/oneapi/dev-utilities/2021.5.0/include
 /opt/intel/oneapi/compiler/2022.0.0/mac/bin/intel64/../../compiler/include/icc
 /opt/intel/oneapi/compiler/2022.0.0/mac/bin/intel64/../../compiler/include
 /Library/Developer/CommandLineTools/usr/bin/../../usr/include/c++/v1
 /System/Library/Frameworks
 /Library/Frameworks
 /Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include
 /usr/local/include
End of search list.
. /Library/Developer/CommandLineTools/usr/bin/../../usr/include/c++/v1/stdio.h
.. /Library/Developer/CommandLineTools/usr/bin/../../usr/include/c++/v1/__config
In file included from stdio.cpp(1):
/Library/Developer/CommandLineTools/usr/bin/../../usr/include/c++/v1/stdio.h(107): catastrophic error: cannot open source file "stdio.h"
  #include_next <stdio.h>
                         ^

compilation aborted for stdio.cpp (code 4)

which is super close, just missing the SDK entirely.

I can just install Xcode, and that seems to trigger the inclusion of the SDK directory, I'm just trying to avoid that.

 

cheers,

- James

0 Kudos
1 Solution
Viet_H_Intel
Moderator
383 Views

How about using -isysroot?

icpc main.cpp -isysroot /path_to/MacOSX.sdk 


View solution in original post

4 Replies
VarshaS_Intel
Moderator
407 Views

Hi,


Thanks for reaching out to us.


We are able to reproduce your issue. We are working on it internally and will get back to you soon.


Thanks & Regards,

Varsha


Viet_H_Intel
Moderator
384 Views

How about using -isysroot?

icpc main.cpp -isysroot /path_to/MacOSX.sdk 


JamesBurgess
Beginner
375 Views

That works for me, thank you!

 

I used, this on my macOS 11.5 machine 

--> clang --version
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
--> icpc -c -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk stdio.cpp

MacOSX.sdk is a symlink to a specific version, presumeably that'll change over time. I tried 10.15, 11.3 and 12.1, they all worked

 

- James

Viet_H_Intel
Moderator
370 Views

Thank you for accepting the solution. Let's close this thread. If you need further assistance, please create a new thread.

Regards,

Viet


Reply