#error “SSE2 instruction set not enabled” when including <emmintrin.h>

醉酒当歌 提交于 2019-12-04 13:46:14

问题


I´m trying to compile some C++ code with cmake and make that uses the include <emmintrin.h> and get the following make error:

 #error "SSE2 instruction set not enabled"

I have an Intel Celeron Dual Core processor with a Linux (Mint) system (Kernel 3.5).

According to Wikipedia the Celeron Dual Core is capable to execute SSE2 instructions and the sse2 flag is set according to /proc/cpuinfo. But the author of this question mentions a limited SSE support of the Intel Celeron.

I've already tried to use the SSE compiler options in my CMakeLists.txt:

set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-msse -msse2 -msse3")

..but nothing changed. cmake . works fine but make gives the error message above.

Do I have to change the settings in CMakeLists.txt or does the Celeron Dual Core simply not (fully) support SSE2?


回答1:


You need to call

set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-msse -msse2 -msse3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2 -msse3")

The CMAKE_C_FLAGS are applied to C files, and from your post's C++ tag, I guess you're compiling C++ files, hence the need to change CMAKE_CXX_FLAGS instead.

As for the positioning of the quotation marks; in your original version, you were setting CMAKE_C_FLAGS to contain 2 separate entries, the first being the starting value of CMAKE_C_FLAGS and the second being the string "-msse -msse2 -msse3".

CMake holds lists like this as semi-colon separated entries. In the case of CMAKE_<lang>_FLAGS, invariably they are a single value comprised of a string containing all the required flags.



来源:https://stackoverflow.com/questions/16410149/error-sse2-instruction-set-not-enabled-when-including-emmintrin-h

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