MAC make编译报错 “clang: error: unsupported option '-fopenmp'”

编译报错

➜  php_mt_seed-main make
gcc -Wall -march=native -mtune=generic -O2 -fomit-frame-pointer -funroll-loops -fopenmp php_mt_seed.c -o php_mt_seed
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
make: *** [php_mt_seed] Error 1

解决参考:
https://www.jianshu.com/p/3ab95219f573#comments

查看自己gcc版本,修改Makefile文件的gcc版本

➜  php_mt_seed-main ls /usr/local/Cellar/gcc
12.2.0 13.1.0

➜  php_mt_seed-main gcc-12 --version
gcc-12 (Homebrew GCC 12.2.0) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

修改Makefile文件

CC = gcc-12
RM = rm -f
......

编译成功

➜  php_mt_seed-main make
gcc-12 -Wall -march=native -mtune=generic -O2 -fomit-frame-pointer -funroll-loops -fopenmp php_mt_seed.c -o php_mt_seed
php_mt_seed.c:47:2: warning: #warning AVX-512 not enabled. Try gcc -mavx512f (on Intel Knights Landing, Skylake-X, or some newer). [-Wcpp]
   47 | #warning AVX-512 not enabled. Try gcc -mavx512f (on Intel Knights Landing, Skylake-X, or some newer).
      |  ^~~~~~~
-macosx_version_min has been renamed to -macos_version_min
posted @ 2024-05-13 17:22  rab3it  阅读(55)  评论(0编辑  收藏  举报