C++ 如何处理“intrin.h:没有这样的文件或目录”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2520683/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to cope with "intrin.h: No such file or directory"?
提问by Mask
#include <intrin.h>
The above will report:
以上将报告:
intrin.h: No such file or directory
Which seems to be a MSVC header file,but I'm using eclipse cdt,how can I make it available?Is there some libraries needed?
这似乎是一个 MSVC 头文件,但我使用的是 eclipse cdt,我怎样才能使它可用?是否需要一些库?
cdt uses MinGW for compiling,but there is no intrin.h
:
cdt 使用 MinGW 进行编译,但没有intrin.h
:
D:\Tools\MinGW\lib\gcc\mingw32.4.5\include>dir *intrin.h
2006-01-17 21:47 34,528 emmintrin.h
2006-01-17 21:47 22,281 mmintrin.h
2006-01-17 21:47 3,586 pmmintrin.h
2006-01-17 21:47 30,925 xmmintrin.h
Is there anyone can help?
有没有人可以帮忙?
回答by leanid.chaika
I have same problem. using eclipse + cdt + mingw32-gcc7.2 + glm (openGL math libraty)
I replace #include <intrin.h>
with #include <x86intrin.h>
add flag to gcc -msse2 and all worked.
我有同样的问题。使用 eclipse + cdt + mingw32-gcc7.2 + glm(openGL 数学库)我#include <intrin.h>
用#include <x86intrin.h>
添加标志替换gcc -msse2 并且一切正常。
回答by Jerry Coffin
This is a header that declares a bunch of "intrinsics" -- functions that are built into the compiler so it can emit inline code for them. If you're using VC++ as the compiler, it should be in the same directory with its other standard headers. If you're using a different compiler, you'll need to change the intrinsics to suit the compiler you are using. gcc, for example, has a lot of similar intrinsic functions, but with slightly different names.
这是一个头文件,它声明了一堆“内部函数”——编译器内置的函数,因此它可以为它们发出内联代码。如果您使用 VC++ 作为编译器,它应该与其他标准头文件位于同一目录中。如果您使用不同的编译器,则需要更改内在函数以适合您使用的编译器。例如,gcc 有很多相似的内在函数,但名称略有不同。
Edit: Given that you're using MinGW (I.e., gcc), you're pretty much stuck with porting the code (or using VC++). If you're dealing with a fairly small amount of code, one way to do that is to comment out the line that includes that header, and try to compile it. The compiler will point out errors where the intrinsic functions were used that gcc doesn't have. You can then look those up (e.g., on MSDN) and try to find something that gcc does provide that does (close enough to) the same thing. Depending on what it uses (and how much) that may be quick and easy, or it may be easier to start over producing new code to do the same things.
编辑:鉴于您使用的是 MinGW(即 gcc),您几乎无法移植代码(或使用 VC++)。如果您正在处理相当少量的代码,一种方法是注释掉包含该标头的行,然后尝试编译它。编译器会指出使用了 gcc 没有的内部函数的错误。然后,您可以查找这些内容(例如,在 MSDN 上)并尝试找到 gcc 确实提供的可以(足够接近)相同内容的内容。取决于它使用什么(以及多少),这可能是快速和简单的,或者重新开始生成新代码来做同样的事情可能更容易。
The *intrinsic headers you've found will (probably) contain declarations of (at least some of) gcc's counterparts to Microsoft's that you need to replace. You'll probably end up using them in the process of porting the code, so don't forget about them. At the same time, just including those headers instead of Microsoft's almost certainly isn't going to make the code work either.
您发现的 *intrinsic 标头将(可能)包含(至少一些)gcc 对应物的声明,您需要替换它。您可能最终会在移植代码的过程中使用它们,所以不要忘记它们。同时,仅仅包含那些标题而不是微软的标题几乎肯定不会使代码工作。