Undefined reference to `clock_gettime`


Hi,

Quick small post:

Whenever you face an error like: Undefined reference to `clock_gettime` while ‘make’, it would be a good idea to edit the makefile and add the following:

LDADD = -lrt

Define this around CXXFLAGS , LDFLAGS etc.

Once defined, make sure that at the end of the file you have the following order of variables (note: some may be missing too).

$(CXX) $(LDFLAGS) -o $(TARGET) $(OBJECTS) $(LDADD)
Advertisements

2 comments

  1. Nice, thanks so much! Simple and fast solution! This post would be more useful if you could explain what causes this error, and why adding this line to makefile solves the problem.

    1. Hey Jack,

      Thanks for the comment. Really glad that you liked the post. I am still not sure why is this particular problem caused. Currently I am not working on BBxM anymore, so maybe later, I could update this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: