http_fetcher編譯問題 - BBS
By Belly
at 2009-06-26T19:33
at 2009-06-26T19:33
Table of Contents
※ 引述《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"
}
之類的
--
[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"
}
之類的
--
Tags:
BBS
All Comments
Related Posts
請問一個問題
By Ivy
at 2009-06-24T17:32
at 2009-06-24T17:32
關於 Mail Server
By Wallis
at 2009-06-16T16:57
at 2009-06-16T16:57
側錄畫面
By Mia
at 2009-06-16T12:51
at 2009-06-16T12:51
ddclient如何設定開機自動執行?
By Leila
at 2009-06-15T20:49
at 2009-06-15T20:49
lighttpd + tomcat
By Frederic
at 2009-06-15T16:01
at 2009-06-15T16:01