QT中 使用类指针时出现错误undefined reference to `s_lp1'

图片说明
如图,还是比较小白,想问一下问题出在哪里。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
QT中编译时出现的undefined reference to ''
这是我QT .pro里面加的rn LIBS += -L../ffmpeg/lib/libavcodec.dll.arnrn我想要调用该库中的avcodec_register_all();函数rn 于是就出现 错误:undefined reference to `avcodec_register_all'rn :-1: 错误:collect2: ld returned 1 exit statusrnrn出现该错误,很明显是在编译的时候,该函数没有找到定义。也就是说没有找到该库。rn可是我在.pro中加了LIBS += -L../ffmpeg/lib/libavcodec.dll.a。不知道是什么原因造成的。
模板类 出现undefined reference to错误
[code=C/C++]rnlinearlist.cpprnrn#include "linearlist.h"rntemplate rnLinearList::LinearList(int nMaxSize)rnrn nMaxListSize = nMaxSize;rn length = 0;rn element = new T[nMaxSize];rnrntemplate rnLinearList::~LinearList()rnrn delete []element;rnrntemplate rnbool LinearList::IsEmpty()constrnrn return length==0;rnrntemplate rnint LinearList::GetLength()constrnrn return length;rnrntemplate rnbool LinearList::Find(int k,T& x)constrnrn if(k<1||k>length)rn return false;rn x = element[k-1];rn return true;rnrntemplate rnint LinearList::Search(const T& x)constrnrn for(int i=0;irnbool LinearList::Delete(int k,T &x)rnrn if(Find(k,x))rn rn for(int i=k;irnbool LinearList::Insert(int k,const T &x)rnrn if(k<0||k>length)rn return false;rn if(length == nMaxListSize)rn return false;rn for(int i=length-1;i>=k;i--)rn rn element[i+1] = element[i];rn rn element[k] = x;rn length++;rn return true;rnrntemplate rnvoid LinearList::OutPut(ostream &out) constrnrn for(int i=0;irnostream &operator<<(ostream &out,const LinearList &x)rnrn x.OutPut(out);rn return out;rnrnrnlinearlist.hrnrn#ifndef LINEARLIST_Hrn#define LINEARLIST_Hrn#include rnusing namespace std;rnrntemplate class LinearList;rntemplate rnostream &operator<<(ostream &out,const LinearList &x);rnrntemplate rnclass LinearListrnrn public:rn LinearList(int nMaxSize=10);rn ~LinearList();rn public:rn bool IsEmpty()const;rn int GetLength()const;rn bool Find(int k,T& x)const;rn int Search(const T& x)const;rn bool Delete(int k,T& x);rn bool Insert(int k,const T& x);rn void OutPut(ostream &out)const;rn private:rn int length;rn int nMaxListSize;rn T *element;rn;rn#endifrnrnmain.cpprnrn#include "linearlist.h"rnint main(void)rnrn LinearList list(5);rn list.Insert(0,1);rn list.Insert(1,2);rn cout<::LinearList(int)'rnmain.cpp:(.text+0x3f): undefined reference to `LinearList::Insert(int, int const&)'rnmain.cpp:(.text+0x63): undefined reference to `LinearList::Insert(int, int const&)'rnmain.cpp:(.text+0x8b): undefined reference to `std::basic_ostream >& operator<< (std::basic_ostream >&, LinearList const&)'rnmain.cpp:(.text+0xac): undefined reference to `LinearList::~LinearList()'rnmain.cpp:(.text+0xc7): undefined reference to `LinearList::~LinearList()'rncollect2: ld returned 1 exit statusrnrn望高手指教rn[/code]
编译出现undefined reference 错误
我现在看的是一个项目中的某部分,项目文件总共大小有50M。我在项目的src源码中的一个模块(例如:osdc)中,增加了两个文件add.cc,add.h.原osdc下面有文件(a.h, a.cc, b.h, b.cc, f.h, f.cc等),其中我实现的时候在a.h中包含了add.h(代码如下:),同时我有add.cc实现了.h中的函数。rn[code=c]#ifndef ADD_Hrn#define ADD_Hrnrntypedef unsigned int usInt;rntypedef char usChar;rn//#define SIZE 300*1024rn#define ArraySize 1024*1024*2rn#define BLOCK_MAX_SIZE 1024*1024rnclass Robin rn public:rn usInt **TA;rn usInt **TB;rn usInt **TC;rn.....rnint rabin(usChar * array,BlockLIinkList* blockLinkList);rn.....rn;rn#endif[/code]rnrn在a.cc中使用:[code=c]rn.....rnBlockLIinkList *blockLinkList = NULL;//使用rabin分块rn Robin *robin = new Robin();rn robin->rabin(temp_data,blockLinkList);rn......rn[/code]rnrn之后,我就执行./configure,然后make,make的时候就出现错误说rnundefined reference to `Robin::rabin(char*, BlockLIinkList*)。rn我不知道是不是因为./configure生成Makefile的时候,不认识我添加的文件(我不熟悉Makefile),我查看通过make之后生成的Makefile时发现,osdc下面除了我新加入的文件add.cc没有,其他所有的.cc文件在Makefile中都能搜索到。rnrn我希望能大家帮帮我,解决这个问题,非常感谢!还有就是针对这种大型项目,如果我增加新的文件的时候需要注意什么?
C++ 使用动态链接库xx.so 时出现undefined reference错误
问题描述最近在用yolo做目标检测的项目。yolo本身的框架接口做的不好,因此想把它编译成动态链接库进行使用。但是对项目生成可执行文件的过程中,编译是没有问题的,但是链接的时候报错:/libyolo.so undefined reference compute_box_iou compute_box_iou是我加入yolo框架里面的一个函数,讲道理应该是在libyolo.so里面能找到的。我用nm指
qt 当中undefined reference to
/home/sdust/untitled1/mainwindow.cpp:154: rn我自己写了个函数bool IsValidEmail(string)rn运行提示rnerror: undefined reference to `MainWindow::IsValidEmail(std::string)'rn急~~~
QT编译错误 undefined reference to
编译QT遇到如下错误,请问怎么解决rn[img=https://img-bbs.csdn.net/upload/201706/22/1498118569_898383.png][/img]
c 中使用 minixml 出现 undefined reference to
在使用 minixml 解析xml ,编译可以通过,但是运行时会出现rnmain.c:12: undefined reference to `mxmlLoadFile'rnmain.c:17: undefined reference to `mxmlFindElement'rnmain.c:20: undefined reference to `mxmlElementGetAttr'rnmain.c:21: undefined reference to `mxmlElementGetAttr'rnmain.c:25: undefined reference to `mxmlFindElement'rnmain.c:28: undefined reference to `mxmlFindElement'rnmain.c:33: undefined reference to `mxmlDelete'rnrn(本身是写java的 因为需求要c 解,看了一下午也没看出啥,求解答)rnrn代码如下rnrn[code=text]#includern#includern#includern#includernrnint main()rnrn FILE *fp;rn mxml_node_t *tree,*node;rnrn fp = fopen("debug_settings.xml", "r");rn tree = mxmlLoadFile(NULL, fp,MXML_TEXT_CALLBACK);rn fclose(fp);rnrn mxml_node_t *id,*password;rnrn node = mxmlFindElement(tree, tree, "note",NULL, NULL,MXML_DESCEND);rnrn printf(" year:%s \n",mxmlElementGetAttr(node,"year"));rn printf(" date:%s \n",mxmlElementGetAttr(node,"date"));rn printf(" month:%s \n",mxmlElementGetAttr(node,"month"));rnrnrnrn id = mxmlFindElement(node, tree, "id",NULL, NULL,MXML_DESCEND);rn printf("[%s\n",id->child->value.text.string);rnrn password = mxmlFindElement(node, tree, "password",NULL, NULL,MXML_DESCEND);rnrn printf("[%s]\n",password->child->value.text.string);rnrnrn mxmlDelete(tree);rnrn return 0 ;rn[/code]
Qt下WSAStartup()编译报“undefined reference”错误
用Qt做一个程序,在windows环境下,我用了如下头文件:rn#ifdef _WIN32rn#include rn#elsern#include rn#endifrn可是编译了对WSAStartup()报错误undefined reference,而且连Socket = socket(PF_INET,SOCK_DGRAM,0);这样的函数都报错,请问这是怎么回事啊?
Qt编译动态库调用错误:undefined reference
今天使用Qt写了个动态库,在其他项目文件调用此动态库时,总是报下面错误: 经过和同事研究,终于发现了问题所在: 1.使用Qt编写动态库时,系统自动生成的.h文件里面有个类,如下面所示 class QHKDLLSHARED_EXPORT QHKDLL { public: QHKDLL(); }; 里面包含 QHKDLLSHARED_EXPORT 这个
gfortran 中使用sleepqq() 出现错误 undefined reference to `sleepqq_'
itime = 1 rncall sleepQQ( itime ) rnrnrn编译过了 rn但是在gfortran -o main test.o时提示错误rnundefined reference to `sleepqq_'rnrnrn求助高手!!!
undefined reference to错误!
下面的代码gcc的时候提示下面的错误,看半天没找出哪有毛病,请教高手指点!rn/tmp/ccmKb9yz.o: In function `sort':rntest.c:(.text+0x1f5): undefined reference to `merge'rncollect2: ld 返回 1rnrn[code=C/C++]rn#include rnrn#define MAXSIZE 8rnint arr[MAXSIZE] = 5, 7, 2, 1, 9, 4, 3, 8 ;rnrnvoid merger(int start, int mid, int end) rn int len1 = mid - start + 1;rn int len2 = end - mid;rn int left[len1];rn int right[len2];rn int i, j, k;rn // 相邻子序列赋值rn for (i = 0; i < len1; i++)rn left[i] = arr[start + i];rn for (j = 0; j < len2; j++)rn right[j] = arr[mid + 1 + j];rn // 合并相邻两个有序子序列rn i = j = 0;rn k = start;rn while (i < len1 && j < len2)rn if (left[i] < right[j])rn arr[k++] = left[i++];rn elsern arr[k++] = right[j++];rn // 检查是否合并完毕rn while (i < len1)rn arr[k++] = left[i++];rn while (j < len2)rn arr[k++] = right[j++];rnrnrnvoid sort(int start, int end) rn int mid;rn if (start < end) rn mid = (start + end) / 2;rn sort(start, mid);rn sort(mid + 1, end);rn merge(start, mid, end);rn rnrnrnint main(int argc, char**argv) rn sort(0, MAXSIZE - 1);rn int index = 0;rn for (index = 0; index < MAXSIZE; index++)rn printf("%d ", arr[index]);rn return 0;rnrnrnrn[/code]
undefined reference to错误。
g++.exe F:\programme\ll.o -o F:\programme\ll.exe -Wall -fpermissive -Wno-sign-compare -grnF:\programme\ll.o(.text+0x29d): In function `ZN7Account4rateEd':rnF:/programme/ll:27: undefined reference to `Account::interestRate'rncollect2: ld returned 1 exit statusrnFailurernrnrn这是错误提示。请大家帮帮忙
Linux下undefined reference to错误
各位:我在写一个双向链表程序。里面有一个FindElebyIndex 函数,是用来查找链表中指定序号元素的,但是我在编译连接时提示如下错误:rn/tmp/ccSh2r0h.o: In function `main':rnDoubleLinkList.c:(.text+0x2ee): undefined reference to `FindEleByIndex'rncollect2: ld returned 1 exit statusrnrn我使用的命令是rngcc DoubleLinkList.c -o DoubleLinkListrnrn然而我把这个函数注释后重新编译通过,然后取消注释,编译也通过,并且运行结果正确。可是不知这里面发生了什么。请有过类似经验的大牛告诉我为什么会这样。为什么注释后编译链接,再取消注释重新编译链接就好了呢?rn我在网上搜这个错误,说是链接错误,但不知道错在了那里。rnrn这是我的源代码:rn//2011/05/08rn//DoubleList的实现和基本操作。包括查找,删除,增加等。rnrn#includern#includernrn#define True 1rn#define False 0rn#define null NULLrnrntypedef struct DNodernrn int data;rn struct DNode* prior; //前驱结点rn struct DNode* next; //后继结点rnDLinkList;rnrn//void PrintDl(DLinkList* dl);rnrn//头插法建表rnint CreateDoubleLinkList_head(DLinkList *dl,int n)rnrn DLinkList* s;int i;rn dl->next=null;rn dl->prior=null;rn for(i=0;idata));rn s->next=dl->next; //s的前驱指向下一个结点rn s->prior=dl; //s插入头结点之后 rn dl->next=s; //dl指向刚插入的结点 rn if(s->next!=null)rn rn s->next->prior=s; //若插入结点的下一个结点不为空,则后继结点的前驱指针域指向srn rn //printf("%d\n",dl->data);rn rn // PrintDl(dl);rn return True;rnrnrn//尾插法rnint CreateDoubleLinkList_tail(DLinkList *dl,int n)rnrn DLinkList *s,*r;rn int i=0;rn dl->next=null;rn dl->prior=null;rn r=dl;rn for(i=0;idata));rn r->next=s; //插入尾结点之后rn s->prior=r; //修改s的前驱指针域rn r=s;rn rn r->next=null; //尾结点next域设为空rn return True;rnrnrn//这里貌似出了一个链接错误:rn///tmp/ccSh2r0h.o: In function `main':rn//DoubleLinkList.c:(.text+0x2ee): undefined reference to `FindEleByIndex'rn//collect2: ld returned 1 exit statusrn//不知是何原因,重新注释这个函数后就正确了。rn//按序号查找第n个元素rnint FindElebyIndex(DLinkList* dl,int index,int *element)rnrnrn int i=0;rn DLinkList* s=dl;rnrn while(s!=null&&inext;rn rnrn if(s==null)rn rn return False;rn rnrn *element=s->data;rnrn return True;rnrnrn//Print DLrnvoid PrintDl(DLinkList* dl)rnrn DLinkList* s=dl->next;rn while(s!=null)rn rn printf("%d\n",s->data);rn s=s->next;rn rnrnrn//Testrnint main()rnrn //头插法建表rn DLinkList* dl =(DLinkList*)malloc(sizeof(DLinkList)); //建立带头结点的双向链表rn printf("输入你想要建表的结点个数:\n");rn int num=0;rn scanf("%d",&num);rn printf("输入这%d数:\n",num);rn CreateDoubleLinkList_head(dl,num);//头插法建表rn printf("链表中有的元素为:\n");rn PrintDl(dl);rn printf("====================================================\n");rn //尾插法建表rn DLinkList* doublelist=(DLinkList*)malloc(sizeof(DLinkList)); //建立带头结点的双向链表rn printf("输入你想要建表的结点个数:\n");rn int count=0;rn scanf("%d",&count);rn printf("输入这%d数:\n",count);rn CreateDoubleLinkList_tail(doublelist,count);//头插法建表rn printf("链表中有的元素为:\n");rn PrintDl(doublelist);rn //查找第n个元素并打印rn int n;rn printf("输入你想找的元素序号:");rn scanf("%d",&n);rn int x=0;rn int *e=&x;rn FindElebyIndex(doublelist,n,e);rn printf("您想找的元素为:%d\n",*e);rnrn return 0;rnrnrn
undefined reference to winmain@16'错误!
#include rnrnint mian(void)rnrn printf("the begin\n");rn goto end;rnrn printf("hello world");rnend:rn printf("the end\n");rn return 0;rnrnrnrn有一个错误“undefined reference to winmain@16” 这是为什么呢?
undefined reference to `WinMain@16'错误
#include rn#include rnrnfloat add_em(long int a, float b)rnrn float result;rn result=a+b;rn return(result);rnrnrnvoid mian(void)rnrn long int i;rn float result =0;rn time_t start_time, stop_time;rn printf("working... \n");rn time(&start_time);rn for (i=1;i<=100000L;i++)rn result+=i;rn time(&stop_time);rn printf("Using loop %d seconds \n", stop_time-start_time);rn printf("Working ... \n");rn time(&start_time);rn for (i=1;i<=100000L;i++)rn result=add_em(i,result);rn time(&stop_time);rn printf("Using fuction %d seconds \n", stop_time-start_time);rnrnrnE:\DEV\other>gcc functovr.c -g -o functovrrnC:/MinGW/bin/../lib/gcc-lib/mingw32/3.2.3/../../../libmingw32.a(main.o)(.text+0xrn97):main.c: undefined reference to `WinMain@16'
undefined reference错误
[code=C/C++]#include rnrnusing namespace std;rnrnclass Arnrnpublic :rn static int i;rnrn static void get();rn;rnvoid A::get()rnrn i=1;rn cout<
undefined reference to 'consine' 错误
我写了在一个文件中写了两个函数:consine(),consine_sve();利用consine_svc()去调用consine(),在生成.o文件时出现错误undefined reference to 'consine',请问是为什么?
ld出现错误undefined reference to printf
有两个文件:rn[code=C/C++]rnmain.crnvoid main()rn subr(4);rn return 0;rnrn[/code]rnrn[code=C/C++]rnsubr.c rnvoid subr(int i)rn printf("i=%d\n", i);rnrn[/code]rnrn然后敲入命令 gcc -c main.c subr.c, 然后链接ld -o prog main.o subr.o, 结果出现链接错误,undefined reference to printf. 我试着加上-L /src/lib, 但是还是一样的错误。 求各位大牛帮忙解决。rn
linux下链接出现undefined reference to错误
下边第一条评论是编译时的输出内容,小弟是在是找不到问题出现在那里了,求大神指点下
求助:出现undefined reference to的错误,解决不了
Makefile:rnCC = g++rnCPPFLAGS = -m32 -I$(HADOOP_INSTALL)/c++/$(PLATFORM)/includernrnmax_temperature: max_temperature.cpp rn $(CC) $(CPPFLAGS) $< -Wall -L$(HADOOP_INSTALL)/c++/$(PLATFORM)/lib -lhadooppipes \rn -lhadooputils -lpthread -g -O2 -o $@rnrnmax_temperature.cpp:rn#include rn#include rn#include rnrn#include "hadoop/Pipes.hh"rn#include "hadoop/TemplateFactory.hh"rn#include "hadoop/StringUtils.hh"rnrnclass MaxTemperatureMapper : public HadoopPipes::Mapper rnpublic:rn MaxTemperatureMapper(HadoopPipes::TaskContext& context) rn rn void map(HadoopPipes::MapContext& context) rn std::string line = context.getInputValue();rn std::string year = line.substr(15, 4);rn std::string airTemperature = line.substr(87, 5);rn std::string q = line.substr(92, 1);rn if (airTemperature != "+9999" &&rn (q == "0" || q == "1" || q == "4" || q == "5" || q == "9")) rn context.emit(year, airTemperature);rn rn rn;rnrnclass MapTemperatureReducer : public HadoopPipes::Reducer rnpublic:rn MapTemperatureReducer(HadoopPipes::TaskContext& context) rn rn void reduce(HadoopPipes::ReduceContext& context) rn int maxValue = INT_MIN;rn while (context.nextValue()) rn maxValue = std::max(maxValue, HadoopUtils::toInt(context.getInputValue()));rn rn context.emit(context.getInputKey(), HadoopUtils::toString(maxValue));rn rn;rnrnint main(int argc, char *argv[]) rn return HadoopPipes::runTask(HadoopPipes::TemplateFactory2());rnrnrn其中HADOOP_INSTALL=/home/hadoop-0.20.2rn PLATFORM=Linux-i386-32rn且在include和lib文件夹里都已包括对应的头文件和库文件,在Windows vista系统下用cygwin编译后出现下面的提示错误:rn$ makerng++ -m32 -I/home/hadoop-0.20.2/c++/Linux-i386-32/include max_temperature.cpp -Warnll -L/home/hadoop-0.20.2/c++/Linux-i386-32/lib -lhadooppipes \rn -lhadooputils -lpthread -g -O2 -o max_temperaturern/tmp/ccKCPihU.o: In function `_ZNK11HadoopPipes16TemplateFactory2I20MaxTemperaturnreMapper21MapTemperatureReducerE13createReducerERNS_13ReduceContextE':rn/home/hadoop-0.20.2/c++/Linux-i386-32/include/hadoop/TemplateFactory.hh:30: undernfined reference to `HadoopPipes::runTask(HadoopPipes::Factory const&)'rn/home/hadoop-0.20.2/c++/Linux-i386-32/include/hadoop/TemplateFactory.hh:30: undernfined reference to `HadoopUtils::toInt(std::basic_string, std::allocator > const&)'rn/home/hadoop-0.20.2/c++/Linux-i386-32/include/hadoop/TemplateFactory.hh:30: undernfined reference to `HadoopUtils::toString(int)'rncollect2: ld returned 1 exit statusrnmake: *** [max_temperature] Error 1rn
写新类时 undefined reference to
我实现stack这个类的时候,然后简单调用测试push函数,出现如下错误rnmain.o(.text+0xf0): undefined reference to `stack::push(basic_string, __default_alloc_template > &)'rncollect2: ld returned 1 exit statusrnrn代码如下 rnstack.hrn 1 #include rn 2 #include rn 3 rn 4 using namespace std;rn 5 rn 6 class stackrn 7 public:rn 10 bool push(string& str);rn 11 // string pop();rn 12 // string find(int pos);rn 13 // int size()return str_vec.size();rn 15 rn 16 private:rn 17 vector str_vec;rn 18 ; rnrnstack.ccrn 1 #incldue "stack.h"rn 2 rn 3 string str;rn 4 rn 14 rn 15 bool stack::push(string& str)rn 16 str_vec.push_back(str);rn 17 return true;rn 18 rn 19 /*rn 20 string stack::pop()rn 21 return str_vec.pop_back();rn 22 rn 23 rn 24 string stack::find(int pos)rn 25 return str_vec[pos];rn 26 */rnrnmain.ccrn 1 #include "stack.h"rn 2 #include rn 3 #include rn 4 rn 5 int main()rn 6 stack _st;rn 7 string word;rn 8 ifstream ifile("./article.txt");rn 9 if(!ifile)rn 10 cerr<<"file error"<>word)rn 14 while(ifile>>word)rn 15 if( !_st.push(word))rn 16 cout<<"push error"<
php make 时的错误:undefined reference to `gdFreeFontCache'
请指教关于php+gd配置的问题rn在php4.3.7环境下:rn./configure --prefix=/usr/local/php --with-apxs=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-vars --with-xml --with-gd=/usr/local/gd-2.0.27rn显示 没有错误,“Thank you for using PHP.”rn而后make,发现有错误:rn/usr/local/php/ext/gd/gd.c:385: undefined reference to `gdFreeFontCache'rncollect2: ld returned 1 exit statusrnmake: *** [sapi/cli/php] Error 1
关于Qt的问题 undefined reference to
问题是这样的:我用类QSvgRenderer 写了一个小程序,结果报错 rnD:\programing\svg/svgwidget.cpp:3: undefined reference to `_imp___ZN10QSvgWidgetC2EP7QWidget'rnD:\programing\svg/svgwidget.cpp:5: undefined reference to `_imp___ZNK10QSvgWidget8rendererEv'rnD:\programing\svg/svgwidget.cpp:6: undefined reference to `_imp___ZN10QSvgWidgetD2Ev'rnD:\programing\svg/svgwidget.cpp:3: undefined reference to `_imp___ZN10QSvgWidgetC2EP7QWidget'rnD:\programing\svg/svgwidget.cpp:5: undefined reference to `_imp___ZNK10QSvgWidget8rendererEv'rnD:\programing\svg/svgwidget.cpp:6: undefined reference to `_imp___ZN10QSvgWidgetD2Ev'rn....rn应该是一些库没链接上?具体应该怎么办呢?rn有一点线索rn在预处理命令里,我用#include 是不行的rn必须用#include rn求大神指点
PHP 7 编译安装时出现 undefined reference to `libiconv' 错误的解决方法
在确认已经安装了libiconv的前提下,make时加个参数 make ZEND_EXTRA_LIBS='-liconv'
qt中使用pthread的undefined错误
pthread的库不是Linux系统的库,所以在使用gcc或g++进行编译的时候要加上-lpthread 如g++ -o test main.cpp -lpthread在qt中使用时也要将库添加进去,如果不添加会出现undefined reference错误。如下:/home/qt-project/First_qt/main.cpp:18: error: undefined reference t
gcc编译出现大量undefined reference
各位大牛好,最近网上找了个贪吃蛇的程序练习练习,敲完代码发现程序无法正常编译。rn一、代码一共两个文件(在同一文件夹内):1.snake.c 2.snake.hrn二、具体操作如下:rn 1.我是这样执行的:gcc -o snake.c runrn 2.然后出现一些错误bug,比如漏字错字之类的,我就开始着手改。那个时候没有一个错误提示说undefined reference。rn 3.就在我把最后一个bug改完之后,出现无数undefined referencern三、如截图所示。rn[img=https://img-bbs.csdn.net/upload/201803/16/1521197287_555151.png][/img][img=https://img-bbs.csdn.net/upload/201803/16/1521197294_300602.png][/img]
使用模板类时undefined reference的问题
自己实现了一个模板类:rn//MyList.hrn#include rn rntemplate rnclass CMyListrnrnprivate:rn std::list m_list;rnpublic:rn int Append(TYPE obj);rn int GetSize() const;rn rn;rnrn//MyList.cpprn#include "MyList.h"rntemplate rnint CMyList::Append(TYPE obj)rnrn m_list.push_back(obj);rn return m_list.size()-1;rn;rn rntemplate rnint CMyList::GetSize()rnrn return m_list.size();rn;rnrn然后在程序中使用该类:rnrn#include "MyList.h"rnrnint main()rnrn CMyList list;rnrn list.Append(1);rnrn int n= list.GetSize();rnrnrn链接时提示错误:rnundefined reference to `CMyList::Append(int)rnundefined reference to `CMyList::GetSize() constrnrn这是为什么呢?
.so里面undefined reference错误
我现在用libZThread这个库。用的时候出现了问题rn/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libZThread.so: undefined reference to `pthread_mutex_trylock'rn/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libZThread.so: undefined reference to `pthread_key_create'rn/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libZThread.so: undefined reference to `pthread_getspecific'rn/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libZThread.so: undefined reference to `pthread_create'rn/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libZThread.so: undefined reference to `pthread_key_delete'rn/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libZThread.so: undefined reference to `pthread_setspecific'rn/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libZThread.so: undefined reference to `pthread_join'rnrn我认为是说libZThread里面用了pthread线程库,但是链接失败。 刚开始是LINKFLAGS没加-lpthread,后面加了还是有这个错误输出。 谁知道什么问题吗?
undefined reference to 错误的解决方法总结
在编写C++时,会遇到一类错误的错。 总结起来为几类 一、是 Linux环境错误  具体没有深入研究,可以参考http://blog.csdn.net/cserchen/article/details/5503556。 二、使用codeblock这类需要自己配置路径,要把所有文件添加到Build target中。配置方法参考下面两个博客:       http://blog.csdn.
出现undefined reference to `QScreenShade::run()'
我的程序中QScreenShade是一个动态库.so的类,里面有自定义的函数void run(),我编译这个动态库可以编译过,也能从其他类打开调用,但如果在其他类中调用这个自定义的函数run()里,编译这个类里会出现undefined reference to `QScreenShade::run()',不知这是什么问题,如果我调用show()这样QScreenShade继承来的函数却不会报错,编译可以通过,也可以运行,真是奇怪了。rn
mingw 出现 undefined reference to 'WinMain@16'
安装完mingw,然后试卷编译一段代码,出现了错误:undefined reference to 'WinMain@16'rn[code=C/C++]rn#include rnint mian(int argc, char *argv[]) rn printf("Hello world");rn return 0;rnrn[/code]rn上面是源代码。rn请问是什么原因导致错误呢?
使用数学函数pow时出现:undefined reference to `pow'
环境是Ubuntu 12.04rn我已经#include , 编译时也加上了 -lm,但还是出现题目中的错误:rnrnCWTNM.c:(.text+0x2ed0): undefined reference to `pow'rnCWTNM.c:(.text+0x2ef5): undefined reference to `pow'rncollect2: ld returned 1 exit statusrnrnrn下面是代码:rn[code=C/C++]pen_score[var] = pow(4.0, clause_weight[var]);[/code]rnrnclause_weight[var]是Int, pen_score[var]是double。rnrn貌似出现的问题跟这些类型完全没关系, 因为根本就undefine了。rn
cups 编程出现 undefined reference
//函数测试小程序 test.cpprnrn#includern#includernusing namespace std;rnint main()rnrn cups_dest_t *dests;rn int num_dests =cupsGetDests(&dests);rn cups_dest_t *dest = cupsGetDest("name",NULL,num_dests,dests);rn cout<<"the name is :"<name<num_options<
gcc编译出现了undefined reference to `exp'
在Ubuntu下编译word.cngcc -lm -pthread word.c -o wordn还是出现了undefined reference to `exp',n后来有gcc -pthread word.c -o word /usr/lib/libm.a则提示没有/usr/lib/libm.a这个文件,nn**有没有有经验的大侠有解决办法?**n
错误求助 undefined reference to `_imp__waveOutGetVolume@8'
[code=c]#include "mainwindow.h"rn#include rn#include rn#include rn#include rn#pragma comment(lib,"winmm.lib")rnrnint main(int argc, char *argv[])rnrn QApplication a(argc, argv);rn MainWindow w;rn w.show();rnrn DWORD lvol;rn waveOutGetVolume(0,&lvol);rn qDebug()<< lvol;rnrn return a.exec();rnrn[/code]rnrn错误信息rndebug/main.o: In function `Z5qMainiPPc':rnC:\Users\redee\Documents\build-TEST-Desktop_Qt_5_7_0_MinGW_32bit-Debug/../TEST/main.cpp:15: undefined reference to `_imp__waveOutGetVolume@8'rncollect2.exe: error: ld returned 1 exit statusrnrn实在查不到相关信息,求助。
使用PIC24FJGA006时出现的问题,undefined reference to `_RPINR19bits'
extern volatile unsigned int RPINR19 __attribute__((__sfr__));rn__extension__ typedef struct tagRPINR19BITS rn union rn struct rn unsigned U2RXR0:1;rn unsigned U2RXR1:1;rn unsigned U2RXR2:1;rn unsigned U2RXR3:1;rn unsigned U2RXR4:1;rn unsigned :3;rn unsigned U2CTSR0:1;rn unsigned U2CTSR1:1;rn unsigned U2CTSR2:1;rn unsigned U2CTSR3:1;rn unsigned U2CTSR4:1;rn ;rn struct rn unsigned U2RXR:5;rn unsigned :3;rn unsigned U2CTSR:5;rn ;rn ;rn RPINR19BITS;rnextern volatile RPINR19BITS RPINR19bits __attribute__((__sfr__));rn这里是官方的定义,rnvoid UART2Init(void)rnrn TRISBbits.TRISB5 = 1;//IO口方向rn TRISBbits.TRISB4 = 0;rn RPINR19bits.U2RXR = 21;//RP21rnrn我这样使用就一直出现上面提示的错误
求救! undefined reference to `vtable for ***错误
/*register.h*/rnpublic:rn explicit regist(QWidget *parent = 0);rn virtual ~regist();rnrn/*register.cpp*/rnregist::~regist()rnrn delete ui;rnrn 错误:undefined reference to `vtable for regist'rn这是在别的文件copy下来的,那个没有错误,怎么这个就出错了。rn求大哥大姐们帮帮忙,SOS!!!!
GCC编译出现undefined reference to `pcap_lex'
代码如下rn#include rn#include rn#include /* GIMME a libpcap plz! */rn#include rn#include rn#include rn#include rnrnint main(int argc, char **argv)rnrn char *dev; /* name of the device to use */ rn char *net; /* dot notation of the network address */rn char *mask;/* dot notation of the network mask */rn int ret; /* return code */rn char errbuf[PCAP_ERRBUF_SIZE];rn bpf_u_int32 netp; /* ip */rn bpf_u_int32 maskp;/* subnet mask */rn struct in_addr addr;rnrn /* ask pcap to find a valid device for use to sniff on */rn dev = pcap_lookupdev(errbuf);rnrn /* error checking */rn if(dev == NULL)rn rn printf("%s\n",errbuf);rn exit(1);rn rnrn /* print out device name */rn printf("DEV: %s\n",dev);rnrn /* ask pcap for the network address and mask of the device */rn ret = pcap_lookupnet(dev,&netp,&maskp,errbuf);rnrn if(ret == -1)rn rn printf("%s\n",errbuf);rn exit(1);rn rnrn /* get the network address in a human readable form */rn addr.s_addr = netp;rn net = inet_ntoa(addr);rnrn if(net == NULL)/* thanks Scott :-P */rn rn perror("inet_ntoa");rn exit(1);rn rnrn printf("NET: %s\n",net);rnrn /* do the same as above for the device's mask */rn addr.s_addr = maskp;rn mask = inet_ntoa(addr);rn rn if(mask == NULL)rn rn perror("inet_ntoa");rn exit(1);rn rn rn printf("MASK: %s\n",mask);rnrn return 0;rnrn
undefined reference to错误如何解决
想写一个在后台监视短信的exe程序,rnMyStart.cpprnrn#include rn#include rn#include // Consolern#include "MyObserver.h"rnrn_LIT(KTextConsoleTitle, "Console");rn_LIT(KTextFailed, " failed, leave code = %d");rn_LIT(KTextPressAnyKey, " [press any key]\n");rnrnLOCAL_D CConsoleBase* console; // write all messages to thisrnrnLOCAL_C void DoStartL()rn rn // Create active scheduler (to run active objects)rn CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();rn CleanupStack::PushL(scheduler);rn CActiveScheduler::Install(scheduler);rnrn CMyObserver* observer = CMyObserver::NewL(*console);rn observer->Load();rn //CActiveScheduler::Start();rn // Delete active schedulerrn CleanupStack::PopAndDestroy(scheduler);rn rnrnGLDEF_C TInt Start()rn rn // Create cleanup stackrn __UHEAP_MARK;rn CTrapCleanup* cleanup = CTrapCleanup::New();rnrn // Create output consolern TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));rn if (createError)rn return createError;rnrn // Run application code inside TRAP harness, wait keypress when terminatedrn TRAPD(mainError, DoStartL());rn if (mainError)rn console->Printf(KTextFailed, mainError);rn console->Printf(KTextPressAnyKey);rn console->Getch();rn rn delete console;rn delete cleanup;rn __UHEAP_MARKEND;rn return KErrNone;rn rnrnrn// Exported Functionsrnrn#ifdef __WINS__rnEXPORT_C TInt WinsMain(TAny* /*aParam*/)rn rn return Start();rn rn#elsernGLDEF_C TInt E32Main()rn rn return Start();rn rn#endifrnrn#ifdef __WINS__rnTInt E32Dll(TDllReason /*aReason*/)rn rn return KErrNone;rn rn#endifrnrnrn// End of filernrnMyObserver.hrn#ifndef MYOBSERVER_Hrn#define MYOBSERVER_Hrnrn// INCLUDESrn// System Includesrn#include // CBase, link against euser.librn#include rn#include rnrn// FORWARD DECLARATIONSrn//class MyClass;rnclass CConsoleBase;rnrn// CLASS DECLARATIONrnrnclass CMyObserver : public CBase, public MMsvSessionObserverrn rn public: // Constructors and destructorrn static CMyObserver* NewL(CConsoleBase& aConsole);rn static CMyObserver* NewLC(CConsoleBase& aConsole);rn virtual ~CMyObserver();rnrn public: // Functions from base classesrn void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3 );rn void Load();rn private: // Constructorsrn CMyObserver(CConsoleBase& aConsole);rn void ConstructL();rnrn private: // Datarn CMsvSession* iMsvSession;rn CMsvEntry* iMsvEntry;rn CConsoleBase& iConsole;rn TMsvId iNewMessageId;rn ;rnrn#endif // MYOBSERVER_HrnrnMyObserver.cpprn#include "MyObserver.h"rnrn// System includesrn#include rn#include rn#include // For CBase, link against euser.librn#include rn#include rnrn//#include rn// User includesrn//#include "MyHeaderFile.h"rnrn#ifdef __WINS__rnconst TMsvId KObservedFolderId = KMsvDraftEntryId;rn#elsernconst TMsvId KObservedFolderId = KMsvGlobalInBoxIndexEntryId;rn#endifrnrn// ================= MEMBER FUNCTIONS =======================rnrnCMyObserver::CMyObserver(CConsoleBase& aConsole) :rniConsole(aConsole)rn rn rnrnCMyObserver::~CMyObserver()rn rn delete iMsvSession;rn delete iMsvEntry;rn rnrnCMyObserver* CMyObserver::NewLC(CConsoleBase& aConsole)rn rn CMyObserver* self = new (ELeave) CMyObserver(aConsole);rn CleanupStack::PushL(self);rn self->ConstructL();rn return self;rn rnrnCMyObserver* CMyObserver::NewL(CConsoleBase& aConsole)rn rn CMyObserver* self = CMyObserver::NewLC(aConsole);rn CleanupStack::Pop(self);rn return self;rn rnrnvoid CMyObserver::ConstructL()rn rn iMsvSession = CMsvSession::OpenAsyncL(*this);rn rnrnvoid CMyObserver::Load()rn rn rnrnvoid CMyObserver::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)rn rn rnrnarmi urel 的时候出现如下错误,还望各位帮帮忙啊rn..\..\..\..\EPOC32\BUILD\SYMBIAN\8.1A\S60_2ND_FP3\SERIES60EX\DATASF\MYSTART\GROUP\MYSTART\ARMI\UREL\MYSTART.in(../../../../EPOC32/BUILD/SYMBIAN/8.1A/S60_2ND_FP3/SERIES60EX/DATASF/MYSTART/GROUP/MYSTART/ARMI/UREL/MYOBSERVER.o)(.text+0x11c):Myobserver.cpp: undefined reference to `CMsvSession::OpenAsyncL(MMsvSessionObserver &)'rnmake: *** [..\..\..\..\EPOC32\RELEASE\ARMI\UREL\MYSTART.EXE] Error 1rnERROR: RCMake failed: (Make): make command exited with result 2. (Reason: The system cannot find the file specified.)rn
Qt 编译出现很多undefined reference to XXX的错误,而且出现错误的头文件是外部库里的
在读研究生,最近老师要我接以前师兄的一个项目,里面用了corba方面的库:rnLIBS += -LC:/omniORB-4.1.4-mingw/lib/x86_win32 \rn -lomniORB414_rt \rn -lomnithread34_rtrnrnrnrnINCLUDEPATH += C:/omniORB-4.1.4/includern else rn include(OMEdit.config)rnrnrnrn于是从网上下了相关的库也放到了相应的位子,但是编译的时候出现海量的如题所说的错误:rn./debug\main.o: In function `_tcf_0':rnc:/omniORB-4.1.4/include/omnithread.h:674: undefined reference to `omni_thread::init_t::~init_t()'rnrn出现错误的头文件就是这个:C:\omniORB-4.1.4\include\omnithread.h
相关热词 c# stream 复制 android c# c#监测窗口句柄 c# md5 引用 c# 判断tabtip 自己写个浏览器程序c# c# 字符串变成整数数组 c#语言编程写出一个方法 c# 转盘抽奖 c#选中treeview