AM我错过了我需要下载的一些额外库?
// test.c
#include <time.h>
#include <stdio.h>
int main()
{
struct timespec x;
clock_gettime(CLOCK_REALTIME, &x);
printf("%d\n", x.tv_sec);
return 1;
}
当我尝试使用MINGW使用GCC对此进行编译时,它将提出以下内容:
gcc test.c
undefined reference to `clock_gettime'
or
gcc test.c -lrt
cannot find -lrt: No such file or directory
检查了我拥有的几个mingw编译器,有些人只是拒绝编译它(下面的`` - ')。
# clock_gettime() in MinGW
- gcc version 5.1.0 (tdm-1)
+ gcc version 5.1.0 (tdm64-1)
+ gcc version 8.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project)
+ gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)
- gcc version 10.3.0 (tdm64-1)
+ gcc version 12.2.0 (MinGW-W64 i686-msvcrt-posix-dwarf)