How to fix "cc1: error: unrecognized command line option '-mavx2'"

Last updated on May 7, 2015 by Dan Nanni

Question: I am trying to compile a program on CentOS, but it complains:
cc1: error: unrecognized command line option '-mavx2'
How can I fix this error?

The error indicates that the GCC compiler you are using does not support -mavx2 option. This option is supposed to enable the use of AVX2 extended instruction sets in the code that you are compiling the program into. As extensions to the x86 instruction set, AVX/AVX2 is designed to improve the performance and parallelism of floating-point intensive computations.

The mavx2 option is supported by GCC version 4.7 and higher. Check your GCC version:

$ gcc --version

Most likely the GCC compiler installed on your CentOS is too old to support mavx2 option.

For example, CentOS 6.X comes with GCC version 4.4.7. If you want to upgrade GCC to versioin 4.7 on CentOS 6.X, you can install devtools. Refer to this guideline to upgrade GCC on CentOS.

Another option is to upgrade to CentOS 7 which comes with GCC 4.8.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean