undefined reference to `clock_gettime' 链接错误问题解决

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/luguifang2011/article/details/41826387

当你编译程序时, 碰到下面的链接错误,

 

timeval.c:(.text+0x6f): undefined reference to `clock_gettime'

则你只需要在你的Makefile文件里面添加    -lrt  ,重新编译即可。

展开阅读全文

undefined reference to 链接错误

07-13

没法贴附件,只能直接贴源码了,在编译时,遇到了链接错误,请各位大侠指正:rn这是一个GOF composite 模式的示意代码:rnrn[color=#FF0000]composite.h //该文件定义composite类,是个模板类[/color][b][/b]rn[code=C/C++]rn#ifndef _COMPOSITE_H_rn#define _COMPOSITE_H_rn#include rnrnnamespace GoFPatternsrnrn using namespace std;rn templatern class Composite : public Componentrn rn public:rn Composite();rn virtual ~Composite();rn void addChild(Component* pchild);rn void removeChild(Component* pchild);rn void clear();rn protected:rn vector children_;rn ;rnrnrn#endifrnrn[/code]rnrncolor=#FF0000]composite.cpp[/color][b][/b]rn[code=C/C++]rn#include rn#include "composite.h"rnrnnamespace GoFPatternsrnrn using namespace std;rn rn// typedef typename vector::iterator ChildIterator;rn rn templatern Composite::Composite()rn rn ;rn rn templatern Composite::~Composite()rn rn ;rn rn templatern void Composite::addChild(Component* pchild)rn rn assert(pchild!=NULL);rn typename vector::iterator itr = find(children_.begin(),children_.end(),pchild);rn if(itr == children_.end())rn rn children_.push_back(pchild);rn rn rn rn templatern void Composite::removeChild(Component* pchild)rn rn assert(pchild!=NULL);rn typename vector::iterator itr = find(children_.begin(),children_.end(),pchild);rn if(itr != children_.end())rn rn children_erase(itr);rn rn rn rn templatern void Composite::clear()rn rn children_.clear();rn rnrnrn[/code] 论坛

没有更多推荐了,返回首页