简体   繁体   中英

emmintrin.h:31:3: error: #error "SSE2 instruction set not enabled" # error "SSE2 instruction set not enabled", "scaling solution"

I have been building multiple projects that require sse2 instruction set. Adding -march=native as mentioned in sse2 instruction set not enabled has done the job till now.

However, in the 3 projects I have needed this, the gcc commands in the makefile were easy to locate and editing slightly the makefile worked. Now I tackle a far more complex makefile generated by cmake. I believe it makes more makefiles in other folders and then runs them etc. So just adding a simple -march=native is neither desirable nor easy and will take a considerable amount of time, if it is feasible afterall.

Is there a way to somehow always have sse2 enabled, opposite to now? I googled this but wasn't able to find something.

Given the fact that non of the makefiles I downloaded from github had -march=native inside, it leads me to believe that indeed there might be some way to set this on gcc/g++ level beforehand?

I found this -mfpmath=sse flag but was not able to formulate a correct gcc/g++ command (if that is related).

Can you help me?

You can add the compiler option -march=native in CMakeLists.txt

SET(PROJECT_FLAGS "-march=native")
SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${PROJECT_FLAGS }")

Or

add_compile_options(-march=native) # CMake 2.8.12 or newer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM