简体   繁体   English

C ++ wxWidgets应用程序未编译

[英]C++ wxWidgets application not compiling

I am having a problem compiling my wxWidgets program. 我在编译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();
    }


}

When I try to compile it, I get the following errors: 当我尝试对其进行编译时,出现以下错误:

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 ===

What am I doing wrong? 我究竟做错了什么? Should I be using OnInit() instead of int main(), even if I want the application to be a console, non-gui one? 即使我希望应用程序是非GUI的控制台,我也应该使用OnInit()而不是int main()吗?

Take a look into your setup.h file for wxWidgets and be sure that wxURL is #define as 查看wxWidgets的setup.h文件,并确保wxURL为#define

#define wxUSE_URL 1

For more information into your setup file (setup.h), take a look at http://wiki.wxwidgets.org/Setup.H 有关进入安装文件(setup.h)的更多信息,请访问http://wiki.wxwidgets.org/Setup.H。

To take a look at a sample of wxURL, take a look into the your wxWidgets folder, go to "samples" and look into "sockets_client". 要查看wxURL的示例,请查看wxWidgets文件夹,转到“示例”,然后查看“ sockets_client”。

There is also reference documents at 也有参考文件,网址为

http://docs.wxwidgets.org/2.9.3/classwx_u_r_i.html http://docs.wxwidgets.org/2.9.3/classwx_u_r_i.html

http://wiki.wxwidgets.org/WxURL http://wiki.wxwidgets.org/WxURL

http://wiki.wxwidgets.org/Download_a_file_from_internet http://wiki.wxwidgets.org/Download_a_file_from_internet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM