1
我在編譯我的wxWidgets程序時遇到問題。未編譯C++ wxWidgets應用程序
#include <wx/wx.h>
#include <wx/url.h>
#include <wx/stream.h>
#include <wx/sstream.h>
int main(int argc, char* argv[])
{
wxURL url(wxT("http://google.com"));
if (url.GetError()==wxURL_NOERR)
{
wxString htmldata;
wxInputStream *in = url.GetInputStream();
if (in && in->IsOk())
{
wxStringOutputStream html_stream(&htmldata);
in->Read(html_stream);
}
wxPuts(html_stream.GetString();
}
}
當我嘗試編譯它,我得到以下錯誤:
main.cpp In function 'int main(int, char**)':
main.cpp 8 error: 'wxURL' was not declared in this scope
main.cpp 8 error: expected ';' before 'url'
main.cpp 9 error: 'url' was not declared in this scope
main.cpp 9 error: 'wxURL_NOERR' was not declared in this scope
main.cpp 12 error: 'wxInputStream' was not declared in this scope
main.cpp 12 error: 'in' was not declared in this scope
main.cpp 15 error: 'wxStringOutputStream' was not declared in this scope
main.cpp 15 error: expected ';' before 'html_stream'
main.cpp 16 error: 'html_stream' was not declared in this scope
main.cpp 18 error: 'html_stream' was not declared in this scope
=== Build finished: 10 errors, 0 warnings ===
我在做什麼錯?我應該使用OnInit()而不是int main(),即使我想讓應用程序成爲控制檯,非gui也是如此?
您是如何編制的? – Arafangion 2012-01-12 04:24:54
'wxURL'聲明的名字空間是什麼? – Karlson 2012-01-12 18:49:47
我認爲你的wx設置不正確。 wx/url.h需要定義wxUSE_URL,否則不聲明wxURL。 – LiMuBei 2012-01-18 09:51:05