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

后端 未结 4 426
予麋鹿
予麋鹿 2020-12-02 07:10

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/in

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 07:50

    example:

    c++ -Wall filefork.cpp -lrt -O2
    

    For gcc version 4.6.1, -lrt must be after filefork.cpp otherwise you get a link error.

    Some older gcc version doesn't care about the position.

提交回复
热议问题