Xcode Intel compiler icc cannot find #include

2019-07-07 09:43发布

Hi I'm trying to compile a gcc based code on Xcode with the icc compiler (11.1.088) but i have the following error:

catastrophic error: could not open source file "algorithm"

After looking to this file, it is located in the gcc include directory, but i get hundreds of errors...

Does anyone have suggestions ?

Thanks.

标签: xcode intel icc
4条回答
Juvenile、少年°
2楼-- · 2019-07-07 10:23

I met this error too, I just forget to change the source from .m to .mm. so, if adjust C++ complier cannot work, try to change the source file.

查看更多
欢心
3楼-- · 2019-07-07 10:41

I was having a really stubborn error very similar to this question but with a different solution.

Algorithm: No such file or directory

My solution:

#ifdef __cplusplus
#include <algorithm>
#endif

I had the #include in a prefix header file (such as the .pch file Xcode gives you in a new project) which was causing it to be included in an Objective-C file, and apparently algorithm is C++ only. Either make sure all your Objective-C files are Objective-C++ (.mm) or add that directive to make sure it doesn't get included in those files.

查看更多
叛逆
4楼-- · 2019-07-07 10:43

What do you have set as your base SDK ? And what version of Xcode ?

FWIW I just tried a test with Xcode 3.2.3 and ICC 11.1 (under OS X 10.6 of course) - created a new C++ console application using the standard Xcode template, added #include <algorithm> to main.cc, switched from the default gcc 4.2 to ICC, and it compiles and runs without warnings or errors. The base SDK is the system default (10.6).

It may just be that you have a bad installation of Xcode and/or ICC, or perhaps you have changed a project setting such as base SDK, and this is causing problems.

查看更多
ら.Afraid
5楼-- · 2019-07-07 10:43

This problem occurred on my machine, while developing an iOS app. Xcode Version 4.6.3 (4H1503) & iOS version 6.0

I'm using AppCode for development and the IDE added (by accident) the following import statement:

#import <c++/4.2.1/ext/algorithm>
查看更多
登录 后发表回答