找不到-lrt的库

时间:2019-03-28 10:04:43

标签: c macos gcc makefile macos-mojave

我正在编译需要-lrt库的Makefile。我的编译器是gcc-8,目前正在OSX Mojave OS上工作。 我使用make命令从终端运行,并且出现以下错误:

  

ld:找不到用于-lrt的库   collect2:错误:ld返回1退出状态   make:*** [eflomal] Error 1

我已经尝试从LDFLAGS中删除-lrt,但是在这种情况下,我会遇到其他错误:

/usr/local/Cellar/gcc/8.3.0/bin/gcc-8 -lm -lgomp -fopenmp  eflomal.o   -o eflomal
Undefined symbols for architecture x86_64:
  "___kmpc_critical", referenced from:
      _.omp_outlined..57 in eflomal.o
      _.omp_outlined..61 in eflomal.o
  "___kmpc_end_critical", referenced from:
      _.omp_outlined..57 in eflomal.o
      _.omp_outlined..61 in eflomal.o
  "___kmpc_for_static_fini", referenced from:
      _.omp_outlined. in eflomal.o
      _.omp_outlined..57 in eflomal.o
      _.omp_outlined..61 in eflomal.o
  "___kmpc_for_static_init_4", referenced from:
      _.omp_outlined. in eflomal.o
      _.omp_outlined..57 in eflomal.o
      _.omp_outlined..61 in eflomal.o
  "___kmpc_fork_call", referenced from:
      _main in eflomal.o
      _align in eflomal.o
ld: symbol(s) not found for architecture x86_64

Makefile标头如下:

export CXX=/usr/local/Cellar/gcc/8.3.0/bin/g++-8
export CC=/usr/local/Cellar/gcc/8.3.0/bin/gcc-8
CFLAGS=-Ofast -march=native -Wall --std=gnu99 -Wno-unused-function -g -fopenmp
# This is more suitable for debugging:
#CFLAGS=-Og -Wall --std=gnu99 -Wno-unused-function -g -fopenmp
#LDFLAGS=-lm -lrt -lgomp -fopenmp
LDFLAGS=-lm -lgomp -fopenmp -lrt

使用gcc编译器而不是clang需要前两行(OSX上的默认设置)。

关于如何解决此问题的任何想法?

0 个答案:

没有答案