gcc编译出现了undefined reference to `exp'

在Ubuntu下编译word.c
gcc -lm -pthread word.c -o word
还是出现了undefined reference to `exp',
后来有gcc -pthread word.c -o word /usr/lib/libm.a则提示没有/usr/lib/libm.a这个文件,

有没有有经验的大侠有解决办法?

2个回答

首先确定有libm.so,虽然一般是肯定有的,locate libm.so确认一下。 要不然把-lm放到gcc编译命令的末尾处试试。

peaktravel
lawen-y 谢谢
接近 5 年之前 回复

我在centos下是这么用的: gcc -o word -L. -pthread -L/usr/lib/ -lm word.o

-L/usr/lib这种一般是用来指定第三方库的位置的。

peaktravel
lawen-y 谢谢
接近 5 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
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]
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
gcc编译问题请教。。。undefined reference to
一个system C(其实就是CPP的一个扩展)程序。编译rnrngcc -c没有问题 但是gcc -o 就不行了报错如下,谁给看看,谢谢。rnrnrn/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o: In function `_start':rn/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18): undefined reference to `main'rn/tmp/ccZKFTjj.o: In function `sc_main':rn/tmp/ccZKFTjj.o(.text+0x5b): undefined reference to `sc_module_name::sc_module_name(char const *)'rn/tmp/ccZKFTjj.o(.text+0x8d): undefined reference to `sc_module_name::sc_module_name(char const *)'rn/tmp/ccZKFTjj.o(.text+0xbf): undefined reference to `sc_module_name::sc_module_name(char const *)'rn/tmp/ccZKFTjj.o(.text+0x15b): undefined reference to `sc_module::operator<<(sc_interface &)'rn/tmp/ccZKFTjj.o(.text+0x166): undefined reference to `sc_module::operator<<(sc_interface &)'rn/tmp/ccZKFTjj.o(.text+0x19c): undefined reference to `sc_module::operator<<(sc_interface &)'rn/tmp/ccZKFTjj.o(.text+0x1a7): undefined reference to `sc_module::operator<<(sc_interface &)'rn/tmp/ccZKFTjj.o(.text+0x1b2): undefined reference to `sc_module::operator<<(sc_interface &)'rn/tmp/ccZKFTjj.o(.data+0x0): undefined reference to `sc_interface type_info node'rn/tmp/ccZKFTjj.o: In function `sc_port_b >::add_interface(sc_interface *)'rnrnrn:。。。。。。。。。。。。。。。。。rnrnrnrn/tmp/ccZKFTjj.o(.sc_pvector_base::gnu.linkonce.t.push_back(void *)+0x24): undefined reference to `sc_pvector_base::resize(int)'rncollect2: ld returned 1 exit status
出现undefined reference to `QScreenShade::run()'
我的程序中QScreenShade是一个动态库.so的类,里面有自定义的函数void run(),我编译这个动态库可以编译过,也能从其他类打开调用,但如果在其他类中调用这个自定义的函数run()里,编译这个类里会出现undefined reference to `QScreenShade::run()',不知这是什么问题,如果我调用show()这样QScreenShade继承来的函数却不会报错,编译可以通过,也可以运行,真是奇怪了。rn
模板类 出现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我希望能大家帮帮我,解决这个问题,非常感谢!还有就是针对这种大型项目,如果我增加新的文件的时候需要注意什么?
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请问是什么原因导致错误呢?
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<
undefined reference to ....
http://codepad.org/7x4aaR3D 不知道问题是什么。。。
undefined reference
编译时出错:rn.o /e/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/pcre_exec.o /e/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/pcre_ord2utf8.o /e/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/pcre_newline.o /e/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/pcre_fullinfo.o /e/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/pcre_xclass.o -L/e/pocobuild/lib/MinGW/ia32 -liphlpapi -lws2_32 -lpcrernCreating library file: e:/pocobuild/lib/MinGW/ia32/libPocoFoundationd.arne:/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/LoggingFactory.o(.text$_ZNK4Poco12InstantiatorINS_15EventLogChannelENS_7ChannelEE14createInstanceEv[Poco::Instantiator::createInstance() const]+0x59): In function `ZN4Poco12InstantiatorINS_17FormattingChannelENS_7ChannelEED1Ev':rne:/poco-1.3.1-data/Foundation/include/Poco/Instantiator.h: undefined reference to `Poco::EventLogChannel::EventLogChannel()'rne:/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/LoggingFactory.o(.text$_ZNK4Poco12InstantiatorINS_21WindowsConsoleChannelENS_7ChannelEE14createInstanceEv[Poco::Instantiator::createInstance() const]+0x59):e:/poco-1.3.1-data/Foundation/include/Poco/Instantiator.h: undefined reference to `Poco::WindowsConsoleChannel::WindowsConsoleChannel()'rne:/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/SyslogChannel.o(.text+0x6e4): In function `ZN4Poco13SyslogChannel4openEv':rne:/poco-1.3.1-data/Foundation/src/SyslogChannel.cpp:76: undefined reference to `openlog'rne:/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/SyslogChannel.o(.text+0x702): In function `ZN4Poco13SyslogChannel5closeEv':rne:/poco-1.3.1-data/Foundation/src/SyslogChannel.cpp:85: undefined reference to `closelog'rne:/pocobuild/Foundation/obj/MinGW/ia32/debug_shared/SyslogChannel.o(.text+0x762): In function `ZN4Poco13SyslogChannel3logERKNS_7MessageE':rne:/poco-1.3.1-data/Foundation/src/SyslogChannel.cpp:94: undefined reference to `syslog'rnrn看样子是是缺少可查了很久rn第一我包含了//这个只有openlog(),closelog()的声明,缺没有定义,rn我不知道到底怎么回事?是不是g++时 没有带什么时候-l参数如果缺少库是缺那个我也不知道,望高手指点rn
Undefined reference
在学习Computer System这本书rn看到第十二章, 按照书上的代码敲了一个Web Server出来rn[code=C/C++]rn#include "csapp.h"rnrnvoid echo(int connfd);rnrnint main( int argc, char **argv)rnrn int listenfd, connfd, port, clientlen;rn struct sockaddr_in clientaddr;rn struct hostent *hp;rn char *haddrp;rn rn if(argc != 2)rn rn fprintf(stderr, "Usage: %s \n", argv[0]);rn exit(0);rn rn port = atoi(argv[1]);rn rn listenfd = Open_listenfd(port);rn while(1)rn rn clientlen = sizeof(clientaddr);rn connfd = accept(listenfd, (SA *)&clientaddr, &clientlen);rn rn hp = Gethostbyaddr( (const char *)&clientaddr.sin_addr.s_addr, sizeof(clientaddr.sin_addr.s_addr), AF_INET); rn haddrp = inet_ntoa(clientaddr.sin_addr);rn printf("Server connected to %s (%s)\n", hp->h_name, haddrp);rn rn echo(connfd);rn Close(connfd);rn rn rn exit(0);rnrnrnvoid echo(int connfd)rnrn size_t n;rn char buf[MAXLINE];rn rio_t rio;rn rn Rio_readinitb(&rio,connfd);rn while( (n = Rio_readlineb(&rio, buf, MAXLINE)) != 0)rn rn printf("Server received %d bytes\n", n);rn Rio_writen(connfd, buf, n);rn rnrnrn[/code]rnrnrnrn在Ubuntu 64bit下面rngcc -Wall server.c -o serverrnrn编译器报错:rnundefined reference to "Open_listenfd"rnundefined reference to "Gethostbyaddr"rnundefined reference to "Close"rnrnundefined reference to "Rio_readinitb"rnundefined reference to "Rio_writen"rnundefined reference to "Rio_readlineb"rnrnrn头文件 csapp.h我是从教材的官网上下载的rn我也看过了, 上面这些“undefined”的函数, 在头文件里面也有。rnrn不明白为什么编译器报错, 望指教!rnrn谢谢!
gcc编译的时候一个undefined reference to `xxx'的一个细节
gcc 编译 引用动态库so的时候,最好将源文件放在动态库的前面,因为gcc的机制会优先前面的文件。 引出这个问题 是在使用glib时出现的。test_glib.c:(.text+0x30): undefined reference to `g_key_file_load_from_file'我使用的 编译命令如下:gcc `pkg-config --cflags --libs glib-2.
cygwin gcc编译连接出错,说是 undefined reference to `_getaddrinfo'
configure结果出现:configure:rnWARNING: winsock2.h: present but cannot be compiledrnconfigure: WARNING: winsock2.h: check for missing prerequisite headers?rnconfigure: WARNING: winsock2.h: see the Autoconf documentationrnconfigure: WARNING: winsock2.h: section "Present But Cannot Be Compiled"rnconfigure: WARNING: winsock2.h: proceeding with the compiler's resultrngcc版本为:3.4.4rn.libs/mms.o:mms.c:(.text+0x1dc0): undefined reference to `_getaddrinfo'rn.libs/mms.o:mms.c:(.text+0x1e6a): undefined reference to `_freeaddrinfo'rn.libs/mms.o:mms.c:(.text+0x1e93): undefined reference to `_freeaddrinfo'rnobjdump -t 结果:rn[ 76](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _srandrn[ 77](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _libiconvrn[ 78](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _strlenrn[ 79](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _closern[ 80](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _freeaddrinforn[ 81](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _connectrn[ 82](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _socketrn[ 83](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _getaddrinforn[ 84](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _sprintfrn[ 85](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _memsetrn[ 86](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _writern[ 87](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _strerrorrn[ 88](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _readrn[ 89](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 ___errnorn[ 90](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _selectrn[ 91](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _strcasecmprn[ 92](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _memcmprn[ 93](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 ___getreentrn[ 94](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _fprintfrn[ 95](sec 0)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _getenvrn相关源代码:rnstatic int fallback_io_tcp_connect(void *data, const char *host, int port)rnrn struct addrinfo *r, *res;rn struct addrinfo hints;rn char port_str[16];rn int i, s;rnrn memset(&hints, 0, sizeof(hints));rn hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV;rn hints.ai_family = AF_UNSPEC;rn hints.ai_socktype = SOCK_STREAM;rn hints.ai_protocol = IPPROTO_TCP;rnrn sprintf(port_str, "%d", port);rn i = getaddrinfo(host, port_str, &hints, &res);rn if (i != 0) rn lprintf("unable to resolve host: %s\n", host);rn return -1;rn rnrn for (r = res; r != NULL; r = r->ai_next) rn s = socket(r->ai_family, r->ai_socktype, r->ai_protocol);rn if (s != -1) rn if (connect(s, r->ai_addr, r->ai_addrlen) != -1) rn freeaddrinfo(res);rn return s;rn rn closesocket(s);rn rn rnrn freeaddrinfo(res);rn return -1;rnrn我怀疑可能是configure的原因,但我不知道怎么弄,请高手解答。
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]
编译别人代码出现 undefined reference to XXX
rnC++访问sqlite3的初体验 - 蛋疼先生的手札 - ITeye技术网站rnhttp://shansun123.iteye.com/blog/365311rnrn里面的那大段rnrn我建立一个console 项目,把“蛋疼先生”这段代码丢进去,并把sqlite3.h 添加到项目里,结果还是提示undefined reference to XXX。(#include "sqlite3.h" 不报错,说明我的确包含了这个头文件不是吗)rn
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。不知道是什么原因造成的。
android jni 编译出现undefined reference问题
undefined reference to 'android::OMXCodec::Create(...)';rn这是在哪个库里面定义的呢?libstagefright?
g++编译occi出现libocci.so: undefined reference ....
急求解决 急急急急急!!! 小弟在线等!!!
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错误
下边第一条评论是编译时的输出内容,小弟是在是找不到问题出现在那里了,求大神指点下
eclipse+mingw编译opengl出现undefined reference
已经在lib中加入了 libglut32.a文件,怎么老编译不了啊
libmp3lame编译出现:undefined reference to 'hip_decode'
![图片说明](https://img-ask.csdn.net/upload/201512/11/1449801757_294680.jpg)rn这是出问题的地方,这三个方法在mpglib_interface.c文件中rn![图片说明](https://img-ask.csdn.net/upload/201512/11/1449801858_108981.png)rn下面是Android.mk文件rn![图片说明](https://img-ask.csdn.net/upload/201512/11/1449801944_736596.png)rn下面是报错信息rn![图片说明](https://img-ask.csdn.net/upload/201512/11/1449802127_857936.png)rnrn这个错误怎么解决?
编译出现 undefined reference to `sqlite3_open',求指教
编译文件按步骤:rnqmake -projectrnqmakernmakern进行的,前两步没有问题,make的时候出现错误,另外已安装了libsqlite3-devrnrn错误代码:rn/mnt/hgfs/student/qt1.cpp:109: undefined reference to `sqlite3_get_table'rn/mnt/hgfs/student/qt1.cpp:115: undefined reference to `sqlite3_free_table'rn/mnt/hgfs/student/qt1.cpp:123: undefined reference to `sqlite3_free_table'rn/mnt/hgfs/student/qt1.cpp:133: undefined reference to `sqlite3_get_table'rn/mnt/hgfs/student/qt1.cpp:140: undefined reference to `sqlite3_free_table'rn/mnt/hgfs/student/qt1.cpp:162: undefined reference to `sqlite3_free_table'rn
编写的自定义函数,出现undefined reference to "xxx"
自己写了一个公有函数 在 CommDefine.h 中定义,现CommDefine.cxx中实现.rnrn在abc.cxx 中include "CommDefine.h"rnrn调用 xxx 函数,编译时出现:rnrnundefined reference to "xxx"rnrn请教高手?问题原因?
XOpenDisplay为什么编译时出现:”undefined reference to XOpenDisplay"?
#include rnrnmain()rnrn Display *display;rnrn display=XOpenDisplay("0:0");rnrn rnrngcc -o x x.c -I/usr/X11R6/Include -L/usr/X11R6 b -IX11rnrn为什么编译时出现:rn”undefined reference to XOpenDisplay"?
求助:出现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
情况是这样的。rn 我现在有一个库,是别人的开发的,编译后生成libpcap_f.a。我用ar -t查看如下:rn[code=c]rn[root@suowenair server]# ar -t libpcap_f.a rnbonree_dump.ornevent.ornhttp_file.ornnetwork_dump.ornport_table.ornssl_file.orntcp_connection.ornthread_mix.orn[/code]rnrn我自己写的另一个程序调用这个库rn但是却出现了rn[code=c]rnserver.o: In function `MsgProc::Proc_e_msg_httpData()':rnserver.cc:(.text+0xa5c): undefined reference to `bonree::EventListenerMaunal::Next()'rnserver.o: In function `MsgProc::CloseAdaptor()':rnserver.cc:(.text+0xf48): undefined reference to `bonree::BonreeDump::Stop()'rnserver.cc:(.text+0xf64): undefined reference to `bonree::BonreeDump::~BonreeDump()'rnserver.o: In function `MsgProc::OpenAdaptor()':rnserver.cc:(.text+0x1174): undefined reference to `bonree::BonreeDump::BonreeDump()'rnserver.cc:(.text+0x11a0): undefined reference to `bonree::EventListenerMaunal::EventListenerMaunal()'rnserver.cc:(.text+0x11fc): undefined reference to `bonree::BonreeDump::RegisterListener(bonree::EventListener*)'rnserver.cc:(.text+0x125c): undefined reference to `bonree::BonreeDump::Start(std::vector, std::allocator >, std::allocator, std::allocator > > > const*)'rn[/code]rnrn我已经引用了该库,但是还是出现这种错误,不理解。我自己开发的程序并且也包含了libpcap_f.a这个库的接口的头文件。
求教undefined reference to
用g++编译一下代码时出现这样的问题:rn undefined reference to `Tree::Tree()'rnrn 1 #include rn 2 #include rn 3 using namespace std;rn 4rn 5 template rn 6 struct CSTnodern 7 rn 8 T data;rn 9 struct CSTnode* firstchild;rn 10 struct CSTnode* nextsibling;rn 11 struct CSTnode* parent;rn 12 ;rn 13rn 14 template rn 15 class Treern 16 rn 17 public:rn 18 Tree();rn 19 virtual ~Tree();rn 20 virtual void getParent() const=0;rn 21 virtual void getFirstChild() const=0;rn 22rn 23 ;rn 24rn 25 template rn 26 class csTree: public Treern 27 rn 28 public:rn 29 csTree();rn 30 ~csTree();rn 31 void getParent() const;rn 32 void getFirstChild() const;rn 33rn 34 private:rn 35 struct CSTnode* root;rn 36 ;rn 37rn 38 template rn 39 csTree::csTree():Tree()rn 40 rn 41 root=new CSTnode;rn 42 root->firstchild=NULL;rn 43 root->nextsibling=NULL;rn 44 rn 45rn 46 template rn 47 csTree::~csTree()rn 48 rn 49 rn 50 template rn 51 void csTree::getParent() constrn 52 rn 53 cout<<""<rn 56 void csTree::getFirstChild() constrn 57 rn 58 cout<<""< cs;rn 66 return 1;rn 67 rn
undefined reference to `CRYPTO_malloc_init'
本人在linux系统安装apache时configure这步没问题:rn./configure --prefix=/usr/local/apache --enable-ssl --enable-rewrite --enable-so --with-ssl=/usr/local/opensslrn 但是make时遇到报错rnhttpd-2.4.20/support/ab.c:2380: undefined reference to `CRYPTO_malloc_init'rnrn请问各位大神如何解决?
编译报错 undefined reference
一个叫 Component 的classrnrn[code=C/C++]//情况1,没有Component.cpp,光有一个Component.h,构造函数定义在其中rnclass Component rnpublic:rn Component() rn...rn;[/code]rn这样就会报rn[color=#FF0000]undefined reference to `Component::Component()'[/color]rnrn如果改成这样就okrn[code=C/C++]//情况2,同时又Component.cpp和Component.h,构造函数定义在cpp中rnrn//file Component.hrnclass Component rnpublic:rn Component();rn...rn;rnrn//file Component.cpprn#include "Component.h"rnComponent::Component() rnrn[/code]rnrnrn如果同时在h和cpp里都定义构造函数,又会出现重复定义的错误rn[color=#FF0000]redefinition of 'Component::Component()'[/color]rn[code=C/C++]//情况3,同时在cpp和h中定义构造函数rnrn//file Component.hrnclass Component rnpublic:rn Component() rn...rn;rnrn//file Component.cpprn#include "Component.h"rnComponent::Component() rnrn[/code]rnrn请问为什么情况1会报错?就是只在.h里定义构造函数。rn
undefined reference to 'pthread_create'
我在linux写下面c程序时,总是报错,说rnundefined reference to 'pthread_create'rnundefined reference to 'pthread_join'rnrn但是我看见pthread.h头文件下面有这个函数的定义啊。这是怎么回事呢?rnrnrnrn#include rn#include rn#include rn#include rn#define NLOOP 5000rnint counter;rnpthread_mutex_t counter_mutex = PTHREAD_MUTEX_INITIALIZER;rnrnvoid *doit(void *vptr)rnrn int i,val;rn for(i=0;i
undefined reference to ... 问题
在写一个内存池,可是在总是出现如题的这个错误rn[code=c]rn#ifndef MEMORYPOOL_Hrn#define MEMORYPOOL_Hrnrn#include rn#include rnrntemplate rnclass MemoryPoolrnrnpublic:rn MemoryPool(int _size = DEFAULTSIZE);rn ~MemoryPool();rn void* alloc(size_t _size);rn void free(void* element, size_t size);rn int size() const rn return _size;rn rn int vaildSize() const rn return _validsize;rn rnprivate:rn enum DEFAULTSIZE = 5;rn /**rn * @brief pool 用来存放内存块的指针rn */rn std::list pool;rn void expandPool(int _len = DEFAULTSIZE);rn int _size;rn int _validsize;rn;rnrntemplate rnMemoryPool::MemoryPool(int _size):rn _size(0),rn _validsize(0)rnrn expandPool(_size);rnrntemplate rnMemoryPool::~MemoryPool()rnrn std::list::iterator ite = pool.begin();rn for (;ite != pool.end();++ite) rn delete[] (*ite);rn rnrntemplate rnvoid* MemoryPool::alloc(size_t /*_size*/)rnrn if (pool.empty()) rn expandPool();rn rn void* t = pool.front();rn pool.pop_front();rn --_validsize;rn return t;rnrntemplate rnvoid MemoryPool::free(void *element, size_t /*size*/)rnrn pool.push_back(element);rn ++_validsize;rnrntemplate rnvoid MemoryPool::expandPool(int _len)rnrn for (int i = 0;i < _len;++i) rn pool.push_back(static_cast(new char[sizeof(T)]));rn rn _validsize += _len;rn _size += _len;rnrnrnrn#endif // MEMORYPOOL_Hrnrn#ifndef TESTOBJ_Hrn#define TESTOBJ_Hrn#include "memorypool.h"rnrnclass Objrnrnpublic:rn Obj() rn static void newPool() rn mPool = new MemoryPool();rn rn static void deletePool() rn delete mPool;rn rn void* operator new(size_t size) rn return mPool->alloc(size);rn rn void operator delete(void* m, size_t size) rn mPool->free(m,size);rn rnrnprivate:rn static MemoryPool *mPool;rn;rnMemoryPool Obj::mPool = NULL;rnrn#endif // TESTOBJ_Hrnrnrn[/code]rnrnrn[img=https://img-bbs.csdn.net/upload/201304/30/1367282753_435259.png][/img]rnrn希望大虾帮解决下
undefined reference to的问题
小弟我入门不久,遇到一个不懂的问题,我写了如下程序,但是编译的时候出现了问题,不知道怎么修正,望各位师傅解答解答rn#include rnvoid printed(int n);rnint main()rn rn int a = 287;rn printed(287);rn getchar();rn return 0;rnrnvoid printd(int n)rnrn if (n < 0) rn rn putchar('-');rn n = -n;rn rn if (n / 10)rn printed(n / 10);rn putchar(n % 10 + '0');rn
NDK undefined reference to `main'
调试NDK中自带的HelloJni例子,编译的时候出现undefined reference to `main'的error,倘若我在.c中加入main函数,那是不是Android工程中就有两个程序入口点了?查了一下,“Add -shared to LD_FLAGS fixed it”,但不太明白,有大神帮个忙吗?帮我看看哪里的设置出现了问题?谢谢啊
undefined reference to 'GameLayer::createScene()'
将Cocos项目导入eclipse当中后,报这个错误,百度到说进入Android.mk添加所有cpp文件,这是什么意思,尝试了一下还是有错。。。
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 "function..."
Redhat 5.0 企业版rnEclipse 3.2 IDErnrn所有写出来的.cpp文件均生成对应.o问件,但总是构建不成功,报错说undefined reference to "function..."。rn去google了,但是很多人给出的都是诸如大小写敏感、路径设置错误、.o文件生成错误,都不能解决问题。rn请高手进来指教!!!!
undefined reference to `dlopen'
我用的是ubuntu8.04, 在eclipse下面开发C++程序rnrno_pModule = dlopen( "./libclassifier.so.1.0", RTLD_LAZY);rnm_pLoadModel = (void(*)(char*)) dlsym( o_pModule, "ClaLoadModel" );rnrn在C++代码里调用动态库时出现如下的错误:rnundefined reference to `dlopen'rnundefined reference to `dlsym'rnundefined reference to `dlsym'rnrn请问如何解决? 望详细点, 谢谢
问题关于undefined reference to
在linux下,我装了一个新的库,叫Gosu的2d游戏引擎。用CodeBlocks打开一个范例程序,报了很多的undefined reference to错误,程序include了gosu/gosu.hpp这个文件,我去/usr/include文件夹下,找到了gosu这个文件夹,文件夹下的文件也都是齐的。但是我不知道cpp文件都放在什么地方。安装的时候没报错。是什么原因呢?rnrn以前也常有这种问题,不知道是怎么回事。rnrn是不是编译器设置不对?GNU GCC Compiler。
编译错误 undefined reference to '__udivdi3'
最近在调试文件系统 exfat,在将打包好的.a库文件加到工程中时出现编译错误:undefined reference to '__udivdi3'。rn在工程中直接使用源代码编译没有这个错误。在网上找了很久没有找有行之有效的方法,只有在这里寻找高手帮忙了。rn打包方法:makefile + mingw32-make.exe,同样的方法打包没有64位数除32位数的库是正常的。rn编辑器:codelitern编译器:ARM-GCCrncpu :ARM9rn系统 :无rnrn
相关热词 c# 去空格去转义符 c#用户登录窗体代码 c# 流 c# linux 可视化 c# mvc 返回图片 c# 像素空间 c# 日期 最后一天 c#字典序排序 c# 截屏取色 c#中的哪些属于托管机制