0
下面是内置到静态用户库调用log.a中的代码。这样做很好。不能在VxWorks RTP应用程序中使用clock_gettime()
#include <time.h>
void logSomething()
{
....
struct timespec tp;
clock_gettime(CLOCK_REALTIME, &tp);
timeStamp = tp;
//log some data with the timestamp
...
}
然后将log.a链接到调用logSomething()的RTP应用程序。当我建立我得到一个链接错误由于“未定义的参考`clock_gettime(INT,的timespec *)'”
我使用的VxWorks 6.9
我从事VxWorks工作已有一段时间,但您可能需要将您的RTP应用程序与包含clock_gettime方法的log.a *和* VxWorks库链接。在Linux中,这将使用'-lrt'。 – rkyser
如果使用C++编译器编译该代码,链接器错误听起来像time.h不是C++安全的。有没有什么区别,如果你宁愿'extern“C”{#include}' –
nos