Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

"Illegal instruction" when running any compiled opencv demo binary & sse3 flag

Hi all,

I just want to notice an issue that happened to me today. I untarred the 2.4.5 version of of OpenCV in a machine running Ubuntu 12.04. Then I went inside the dir, create de build directory and run cmake

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/usuario/inst_opencv_245 ..

Everything seemed to go ok so I did "make install" and the whole bunch started to compile. It ended up without any problem (I did this installation before on other machines) but as soon as I tried to execute any binary, such as opencv_test_core nothing started but an "Illegal instruction" message.

I googled this issue around for a little bit and I saw sth related to sse, processors and things like that. So I did "cat /proc/cpuinfo" and this was the output:

processor : 0 vendor_id : AuthenticAMD cpu family : 15 model : 12 model name : AMD Athlon(tm) 64 Processor 3000+ stepping : 0 cpu MHz : 1000.000 cache size : 512 KB fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 1 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext lm 3dnowext 3dnow up bogomips : 2000.07 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management: ts fid vid ttp

For my surprise, running the above cmake command showed that an sse3 flag was enabled for both c and c++ gcc compilers. So what I did was to comment the lines 140 and 144 of the file OpenCVCompilerOptions.cmake under the cmake directory.

# GCC depresses SSEx instructions when -mavx is used. Instead, it generates if(NOT OPENCV_EXTRA_CXX_FLAGS MATCHES "-mavx") if(ENABLE_SSE3) # add_extra_compiler_option(-msse3) endif() if(ENABLE_SSSE3) # add_extra_compiler_option(-mssse3) endif() if(ENABLE_SSE41) add_extra_compiler_option(-msse4.1) endif()

Then I did cmake again and after compiling and installing it again everything worked perfectly.

I dunno if this is a bug or what. It is just in case anyone had this problem.

Miguel

P.S.: this is my first post, sorry for the format.