views:

1492

answers:

1

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.

+3  A: 

Add -lrt to the list of libraries you link to

Dmitry Yudakov
that works if I compile manually - any idea how I automate that in codeblocks?
naspinski
try Project -> Build Options -> Linker Settings ; then add library rt
Dmitry Yudakov