作者weiyucsie (选择那刻 才算开始)
看板FreeBSD
标题Re: [问题] http_fetcher编译问题
时间Fri Jun 26 19:33:15 2009
※ 引述《sacanner (Sam)》之铭言:
[deleted]
: 可是却仍发生undefined reference问题(错误如下)
: g++ -I../include -L../lib -lhttp_fetcher t.cpp
: /var/tmp//ccjBAMrM.o(.text+0x12b): In function `main':
: : undefined reference to `http_fetch(char const*, char**)'
: CODE:
[deleted]
: int main()
: {
: char *fileBuf[4000];
: http_fetch("http://www.yahoo.com.tw", fileBuf);
: return 0;
: }
稍微下载测试後
发现http_fetch的prototype为
int http_fetch(const char *url, char **fileBuf);
对照其comment
Download the page, registering a hit. If you pass it a NULL for fileBuf,
'url' will be requested but will not remain in memory (useful for
simply registering a hit). Otherwise necessary space will be allocated
and will be pointed to by fileBuf. Note that a NULL byte is
added to the data, so the actual buffer will be the file size + 1.
看起来是你的用法错了
--
其实我想到另外一点XD
你可能需要确定他函式库是用c还是c++编译
如果用C编译的话,可能在include的时候
要
extern "C" {
#include "../include/http_fetcher.h"
}
之类的
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.114.203.6
※ 编辑: weiyucsie 来自: 140.114.203.6 (06/26 19:53)