Re: [問題] http_fetcher編譯問題

看板FreeBSD作者 (選擇那刻 才算開始)時間15年前 (2009/06/26 19:33), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/4 (看更多)
※ 引述《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)
文章代碼(AID): #1AHB7-VH (FreeBSD)
討論串 (同標題文章)
文章代碼(AID): #1AHB7-VH (FreeBSD)