用NDK编译webrtc aecm模块出现‘undefined reference to’ 错误问题解决办法

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/hongdameng/article/details/53436020

最近在编译webrtc aecm模块的时候,代码中明明已经包含C文件的引用,但是编译的时候一直‘undefined reference to XXXXXX’ ,如图




解决方法: 在MK文件里加多一行  

LOCAL_ALLOW_UNDEFINED_SYMBOLS := true

展开阅读全文

编译出现undefined reference 错误

02-18

我现在看的是一个项目中的某部分,项目文件总共大小有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我希望能大家帮帮我,解决这个问题,非常感谢!还有就是针对这种大型项目,如果我增加新的文件的时候需要注意什么? 论坛

关于用G++编译 undefined reference to 的问题!

05-07

照着书上的数据结构算法编链表的,编译通不过。显示undefined reference to `AList::insert(int const&)rnrn书上的算法是这样的,先是一个抽象类ADT,rn/***********Abstract_List.h******************/rntemplate class List rn public:rn //清空rn virtual void clear( ) = 0;rnrn //插入rn virtual bool insert( const Elem& ) = 0;rnrn //添加rn virtual bool append( const Elem& ) = 0;rnrn //移除rn virtual bool remove( Elem& ) = 0;rn 。。。省略。。。。。rnrnrn然后用数组方式实现链表rn/***********Array_List.h*********************/rn#include "Abstract_List.h"rn#define DefaultListSize 200rnrntemplate< class Elem > // Array-based list implementationrnclass AList : public List< Elem > //继承抽象类rn private:rn int maxSize; //Maximum size of listrn int listSize; //Actual number of elements in listrn int fence; //Position of fencern Elem *listArray; // Array holding list elementsrnrn public:rn AList( int size = DefaultListSize ) //Constructorrn maxSize = size;rn listSize = fence = 0;rn listArray = new Elem[maxSize];rn rn ~AList( ) delete [] listArray; //Destructorrn void clear( ) rn delete [] listArray;rn listSize = fence = 0;rn listArray = new Elem[maxSize];rn rn bool insert( const Elem& ); 1 //这三个函数在另外的Cpp中实现。rn bool append( const Elem& ); 2rn bool remove( Elem& ); 3rn void setStart( ) fence = 0; rn 。。。省略。。。。。rnrnrnrn/***************Array_List.cpp****************/rn#include "Array_List.h"rnrn分别为3个实现。rntemplate // Insert at front of right partitionrnbool AList::insert( const Elem& item ) rn if( listSize == maxSize ) return false; //List is fullrn for( int i = listSize; i > fence; i-- ) // Shift Elems uprn listArray[i] = listArray[i-1]; // to make roomrn listArray[fence] = item;rn listSize++; //Increment list sizern return true;rnrnrntemplate //Append Elem to end of the list rnbool AList::append( const Elem& item ) rn if( listSize == maxSize ) return false;rn listArray[listSize++] = item;rn return true;rnrnrn//Remove and return first Elem in right partitionrntemplate rnbool AList::remove( Elem& it ) rn if( rightLength( ) == 0 ) return false; //Nothing in rightrn it = listArray[fence]; //Copy removed Elemrn for( int i = fence; i < listSize - 1; ++i )//Shift them downrn listArray[i] = listArray[i+1];rn listSize--;rn return true;rnrnrn/***************************main.c**************/rn#include "Array_List.h"rn#include rnusing namespace std;rnrnrnint main( int argc, char* argv[] ) rn cout << "Hello world" << endl;rn AList< int > ArrList( 100 ); rn return 0;rnrnmain函数声明了一个链表变量就报错了。rn如果不声名变量的话,可以通过编译,输出hello world。rn不知道这个是什么问题,求大虾指教。rn四个文件都在同一目录下,编译命令用 rng++ Array_main.cpp Array_List.cpprnrnrn出错信息为。rn g++ -o abc Array_main.cpp Array_List.cpprn/tmp/cc5kzKtg.o:(.rodata._ZTV5AListIiE[vtable for AList]+0xc): undefined reference to `AList::insert(int const&)'rn/tmp/cc5kzKtg.o:(.rodata._ZTV5AListIiE[vtable for AList]+0x10): undefined reference to `AList::append(int const&)'rn/tmp/cc5kzKtg.o:(.rodata._ZTV5AListIiE[vtable for AList]+0x14): undefined reference to `AList::remove(int&)'rn rn顺便求大虾指教一下怎么写个makefile文件出来,谢谢。rn 论坛

模板类 出现undefined reference to错误

04-19

[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] 论坛

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