在 Code::Blocks 中设置 wxWidgets?
我试图让这段代码工作,但我做不到。我希望它可以运行,这样我就可以在我的其他项目中使用它。我刚刚在网上看到这个。这是关于wxOGL的。
#include <wx/wx.h>
#include <wx/ogl/ogl.h>
#include <wx/cursor.h>
class MyApp: public wxApp
{
virtual bool OnInit();
};
class MyFrame: public wxFrame
{
wxDiagram * diagram;
wxShape * shape;
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
~MyFrame();
};
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame(_("wxWidgets - Object Graphics Library"),
wxPoint(50, 50), wxSize(450, 340) );
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
wxShapeCanvas *canvas = new wxShapeCanvas(this, wxID_ANY, pos, size, 0, _T("a"));
canvas->SetBackgroundColour(*wxWHITE);
canvas->SetCursor(wxCursor(wxCURSOR_CROSS));
diagram = new wxDiagram();
canvas->SetDiagram(diagram);
shape = new wxCircleShape(20.0);
shape->SetX(25.0);
shape->SetY(25.0);
canvas->AddShape(shape);
diagram->ShowAll(1);
}
MyFrame::~MyFrame()
{
delete shape;
delete diagram;
}
我不知道它有什么作用,我只是想看看它。当我在 Code::Blocks 中编译它时,它不断返回错误“wx/wx.h:没有这样的文件目录”和其他错误。有人能解决这个问题吗?
I'm trying to make this code work but I can't. I'm hoping that it could run so I can use it in my other project. I just saw this on the web. It is about wxOGL.
#include <wx/wx.h>
#include <wx/ogl/ogl.h>
#include <wx/cursor.h>
class MyApp: public wxApp
{
virtual bool OnInit();
};
class MyFrame: public wxFrame
{
wxDiagram * diagram;
wxShape * shape;
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
~MyFrame();
};
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame(_("wxWidgets - Object Graphics Library"),
wxPoint(50, 50), wxSize(450, 340) );
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
wxShapeCanvas *canvas = new wxShapeCanvas(this, wxID_ANY, pos, size, 0, _T("a"));
canvas->SetBackgroundColour(*wxWHITE);
canvas->SetCursor(wxCursor(wxCURSOR_CROSS));
diagram = new wxDiagram();
canvas->SetDiagram(diagram);
shape = new wxCircleShape(20.0);
shape->SetX(25.0);
shape->SetY(25.0);
canvas->AddShape(shape);
diagram->ShowAll(1);
}
MyFrame::~MyFrame()
{
delete shape;
delete diagram;
}
I don't know what it does, I just want to take a look at it. When I compile it in Code::Blocks, it keeps returning error saying "wx/wx.h: no such file directory" and other errors. Does anyone can fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通常,像这样的包将使用配置脚本来指定编译/链接器参数。因此,如果您只是从命令行使用 gcc 编译器:
在 Code::Blocks 中,您只需右键单击您的项目,“构建选项...”,在左侧窗口中选择项目名称(如果发布/调试是当您执行下一步时突出显示,更改将仅适用于发布或调试版本),编译器设置选项卡,其他选项选项卡,然后插入:
然后选择链接器设置选项卡并在其他链接器选项窗口中添加:
这两件事通常是不过,在 C::B 中为您设置(OGL 库除外)。
此外,该程序使用对象图形库(OGL),它不是 wxWidgets 基本集的一部分,因此您还必须显式包含以下内容:
请记住,-2.8 部分是版本号,在您的计算机上可能有所不同。假设已安装,您可以通过发出命令 (linux) 找出您拥有的版本:
它将查找您的用户库区域中名称中带有“wx”和“ogl”的所有文件。
祝你好运
/艾伦
Often packages like this will use config scripts to specify the compile/linker parameters. So if you are just using the gcc compiler from the command line:
In Code::Blocks you just right-click your project, Build Options..., select the name of your project in the left hand window (if Release/Debug are highlighted when you do the next step the changes will only be for either the Release or Debug version), Compiler-Settings tab, Other-options tab, and insert:
Then choose Linker-settings tab and in the Other-linker-options window add:
These two things would normally be set up for you in C::B though (except for the OGL library).
In addition this program uses the Object Graphics Library (OGL) which isn't part of the basic set for wxWidgets so you'll have to explicitly include the following as well:
Keep in mind the -2.8 part is the version number which might different on your machine. You can figure out what version you have, assuming it is installed, by issuing the command (linux):
which will find all the files in your user library area with "wx" and "ogl" in their names.
Good luck
/Alan
您的编译器找不到您的wxWidgets安装。Code::Blocks people 有一些设置文档。
Your compiler can't find your wxWidgets install. The Code::Blocks people have some documentation for setting that up.
该错误意味着要么没有正确安装 wxWidgets 开发文件,要么您的项目设置已损坏。
That error means that either haven't wxWidgets development files installed properly, or your project settings are broken.