Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 820
Suzana Avatar asked May 07 '13 02:05

Suzana


1 Answers

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.

like image 97
Fraser Avatar answered Oct 31 '22 00:10

Fraser