如何在linux下使用wxwidget2.9.2

发布于 2024-12-18 23:08:16 字数 516 浏览 0 评论 0原文

我是 wxWidgets
新手 我的平台是fedora 16,gcc 4.6.2编辑器是vim
我在sourceforge上下载了wxwidget.gz.tar文件,并尝试编译。

我在 bash 中输入 ./configure --with-gtk --enable-unicode --disable-shared ,然后进行安装,wxwidget 安装完成。

我尝试编译一个文件:test.cpp 文件内容如下:

#include <wx/wx.h>
int main()
{
    return 0;
}//i have copied the head file folder to /usr/include/wx

use gcc -o

gcc 显示 wx/platform.h:wx/setup.h, no such file

我该如何解决这个问题?

I am new to wxWidgets
My platform is fedora 16,gcc 4.6.2 editor is vim
I download the wxwidget.gz.tar file on sourceforge, and tried to compile.

I typed ./configure --with-gtk --enable-unicode --disable-shared in bash, and make install and the wxwidget install is finished.

I tried to comile a file: test.cpp
Here are the contents of the file:

#include <wx/wx.h>
int main()
{
    return 0;
}//i have copied the head file folder to /usr/include/wx

use gcc -o

gcc shows the wx/platform.h:wx/setup.h, no such file

How do I solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尸血腥色 2024-12-25 23:08:16

您应该使用 wx-config --cxxflags 和 wx-config --libs 来获取编译所需的包含路径、标志和库。

更详细地说:您需要告诉编译器在哪里可以找到包含文件以及需要链接哪些库。 wx-config 是一个方便的程序,可以为您提供该信息。在我的系统上,wx-config 的输出如下所示:

-I/usr/local/lib/wx/include/gtk2-unicode-2.9 -I/usr/local/include/wx-2.9 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -L/usr/local/lib -pthread   -lwx_gtk2u_xrc-2.9 -lwx_gtk2u_html-2.9 -lwx_gtk2u_qa-2.9 -lwx_gtk2u_adv-2.9 -lwx_gtk2u_core-2.9 -lwx_baseu_xml-2.9 -lwx_baseu_net-2.9 -lwx_baseu-2.9

让我们看一下这个简约的 wxWidgets 应用程序:

#include <wx/app.h>
#include <wx/frame.h>

/** Main application class.
 *  This class is derived from the main wxWidgets application class.
 */
class MyApp : public wxApp
{
public:
    /// Initialization function. Called at startup.
    virtual bool OnInit();
    virtual ~MyApp();
};

DECLARE_APP(MyApp);

IMPLEMENT_APP(MyApp);

bool MyApp::OnInit()
{
    if ( !wxApp::OnInit() )
        return false;

    wxFrame* MainFrame = new wxFrame(NULL, wxID_ANY, wxT("MyApp"));
    MainFrame->Show();

    return true;
}

MyApp::~MyApp() {}

您可以使用以下调用对其进行编译:

gcc OUTPUT_OF_WX-CONFIG test.cpp -o test

其中 OUTPUT_OF_WX-CONFIG 是如上所述的标志和库目录,test.cpp 包含上述源代码。如果您的 wxWidgets 安装设置正确,则应该可以正常编译并运行(将显示一个空窗口)。

You should use wx-config --cxxflags and wx-config --libs to get the include paths, flags and libraries you need in order to compile.

To elaborate more: you need to tell the compiler where to find the include files and what libraries need to be linked. wx-config is a convenience program that will give you that information. On my system the output from wx-config looks like this:

-I/usr/local/lib/wx/include/gtk2-unicode-2.9 -I/usr/local/include/wx-2.9 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -L/usr/local/lib -pthread   -lwx_gtk2u_xrc-2.9 -lwx_gtk2u_html-2.9 -lwx_gtk2u_qa-2.9 -lwx_gtk2u_adv-2.9 -lwx_gtk2u_core-2.9 -lwx_baseu_xml-2.9 -lwx_baseu_net-2.9 -lwx_baseu-2.9

Let's take this minimalistic wxWidgets application:

#include <wx/app.h>
#include <wx/frame.h>

/** Main application class.
 *  This class is derived from the main wxWidgets application class.
 */
class MyApp : public wxApp
{
public:
    /// Initialization function. Called at startup.
    virtual bool OnInit();
    virtual ~MyApp();
};

DECLARE_APP(MyApp);

IMPLEMENT_APP(MyApp);

bool MyApp::OnInit()
{
    if ( !wxApp::OnInit() )
        return false;

    wxFrame* MainFrame = new wxFrame(NULL, wxID_ANY, wxT("MyApp"));
    MainFrame->Show();

    return true;
}

MyApp::~MyApp() {}

You can compile this using the following call:

gcc OUTPUT_OF_WX-CONFIG test.cpp -o test

where OUTPUT_OF_WX-CONFIG is the flags and library directories like above and test.cpp contains the above source code. If you wxWidgets installation is setup properly this should compile and run fine (will show an empty window).

岁月苍老的讽刺 2024-12-25 23:08:16

我强烈鼓励您使用 CMake 来管理 wxWidgets 应用程序构建过程。

您可以在此处找到与 CMake 配置文件捆绑在一起的 LiMuBei 示例应用程序。

只需克隆项目并按照“README”文件中的说明进行操作即可。

git clone https://bitbucket.org/vizz/wxstartapp.git

基本思想是描述您的项目源、依赖项,并使用 CMake 通过适当的内置宏来处理所有“收集过程”(这样您就不必担心“wx-config”及其选项)/功能。

例如,要配置 wxWidgets 项目,您可以编写:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(wxstartapp)

FIND_PACKAGE(wxWidgets REQUIRED core base)
IF(wxWidgets_FOUND)
INCLUDE(${wxWidgets_USE_FILE})

...some CMake stuff here...

INCLUDE_DIRECTORIES(
    ... some additional CMake stuff here...
    ${wxWidgets_INCLUDE_DIRS}
)
TARGET_LINK_LIBRARIES(wxstartapp ${wxWidgets_LIBRARIES})
ENDIF(wxWidgets_FOUND)

请自行查看“CMakeLists.txt”文件。

I STRONGLY encourage you to use CMake for managing you wxWidgets application build process.

You can find LiMuBei's example app bundled with CMake configuration file here.

Just clone the project and follow the instructions int the "README" file.

git clone https://bitbucket.org/vizz/wxstartapp.git

The basic idea is to describe your project sources, dependencies and to use CMake to handle all the "gathering process" ( so that you don't have to worry about "wx-config" and its options ) through appropriate built-in macros/functions.

For example, to configure you wxWidgets project you would write:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(wxstartapp)

FIND_PACKAGE(wxWidgets REQUIRED core base)
IF(wxWidgets_FOUND)
INCLUDE(${wxWidgets_USE_FILE})

...some CMake stuff here...

INCLUDE_DIRECTORIES(
    ... some additional CMake stuff here...
    ${wxWidgets_INCLUDE_DIRS}
)
TARGET_LINK_LIBRARIES(wxstartapp ${wxWidgets_LIBRARIES})
ENDIF(wxWidgets_FOUND)

See the "CMakeLists.txt" file for yourself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文