[英]C++ wxWidgets application not compiling
我在編譯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 ===
我究竟做錯了什么? 即使我希望應用程序是非GUI的控制台,我也應該使用OnInit()而不是int main()嗎?
查看wxWidgets的setup.h文件,並確保wxURL為#define
為
#define wxUSE_URL 1
有關進入安裝文件(setup.h)的更多信息,請訪問http://wiki.wxwidgets.org/Setup.H。
要查看wxURL的示例,請查看wxWidgets文件夾,轉到“示例”,然后查看“ sockets_client”。
也有參考文件,網址為
http://docs.wxwidgets.org/2.9.3/classwx_u_r_i.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.