LMSouq
general-dev Open

C++ error: undefined reference to 'clock_gettime' and 'clock_settime'

NA
naspinski
1 month ago
3 views
Problem Description
I am pretty new to Ubuntu, but I can't seem to get this to work. It works fine on my school computers and I don't know what I am not doing. I have checked **usr/include** and time.h is there just fine. Here is the code: #include <iostream> #include <time.h> using namespace std; int main() { timespec time1, time2; int temp; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1); //do stuff here clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2); return 0; } I am using CodeBlocks as my IDE to build and run as well. Any help would be great, thank you.

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base