Xcode Intel compiler icc cannot find #include <algorithm>

馋奶兔 提交于 2019-12-10 18:43:56

问题


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.


回答1:


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.




回答2:


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.




回答3:


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>



回答4:


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.



来源:https://stackoverflow.com/questions/4244727/xcode-intel-compiler-icc-cannot-find-include-algorithm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!