Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22199

Why is clock_gettime() not working with MinGW, even though I have time.h

$
0
0

The linker keeps telling me that clock_gettime() is undefined.

I have tried using -lrt but then gcc says that it can't find that either.

Am I missing some extra library I needed to download?

// 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;}

When I try to compile this using GCC with MinGW, it puts out this:

gcc test.cundefined reference to `clock_gettime'

or

gcc test.c -lrtcannot find -lrt: No such file or directory

Viewing all articles
Browse latest Browse all 22199

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>