在MAC中使用wxWidgets编译测试程序

发布于 2024-12-06 19:48:52 字数 3451 浏览 1 评论 0原文

操作系统:MAC X 10.7.0

Mac OS X 在/usr 中安装旧版本的wxMac(wxMac-2.8.8.1),但我在/usr/local 中安装较新版本(wxMac-2.8.12.0)。为了安装它,我使用以下标志编译新的:

arch_flags="-arch i386" ./configure CFLAGS="$arch_flags" CXXFLAGS="$arch_flags" CPPFLAGS="$arch_flags" LDFLAGS="$arch_flags" OBJCFLAGS="$arch_flags" OBJCXXFLAGS="$arch_flags" --enable-unicode --enable-debug - -disable-shared

然后我编写一个简单的程序(hello2.cpp)来测试它:

#include "wx/wx.h"

class HelloWorldApp : public wxApp
{
public:
    virtual bool OnInit();
private:
    wxButton *button;
};


IMPLEMENT_APP(HelloWorldApp)

bool HelloWorldApp::OnInit()
{
    wxFrame *frame = new wxFrame((wxFrame*) NULL, -1, _T("Hello wxWidgets World"));
    frame->CreateStatusBar();
    frame->SetStatusText(_T("Hello World"));
    button = new wxButton((wxFrame *)frame, -2, _T("123"));
    frame->Show(TRUE);
    SetTopWindow(frame);

    return true;
}

我编译这个测试在带有标志的命令行中运行程序:

g++ hello2.cpp /usr/local/bin/wx-config --cxxflags --libs -o hello2

但我收到一些警告和错误。我是Mac编程新手,所以我不知道原因。我只想说:救命啊!

以下是编译的结果:

ld: warning: in /usr/local/lib/libiconv.dylib, file wasbuilt for unsupported file format that is not the Architecture being linked (i386) 未定义的符号: “_libiconv_open”,引用自: libwx_base_carbonud-2.8.a(baselib_strconv.o) 中的 wxMBConv_iconv::wxMBConv_iconv(wchar_t const*) libwx_base_carbonud-2.8.a(baselib_strconv.o) 中的 wxMBConv_iconv::wxMBConv_iconv(wchar_t const*) libwx_base_carbonud-2.8.a(baselib_strconv.o) 中的 wxMBConv_iconv::wxMBConv_iconv(wchar_t const*) libwx_base_carbonud-2.8.a(baselib_strconv.o) 中的 wxMBConv_iconv::wxMBConv_iconv(wchar_t const*) libwx_base_carbonud-2.8.a(baselib_strconv.o) 中的 wxMBConv_iconv::wxMBConv_iconv(wchar_t const*) libwx_base_carbonud-2.8.a(baselib_strconv.o) 中的 wxMBConv_iconv::wxMBConv_iconv(wchar_t const*) libwx_base_carbonud-2.8.a(baselib_strconv.o) 中的 wxMBConv_iconv::wxMBConv_iconv(wchar_t const*) libwx_base_carbonud-2.8.a(baselib_strconv.o) 中的 wxMBConv_iconv::wxMBConv_iconv(wchar_t const*) “_libiconv”,引用自: libwx_base_carbonud-2.8.a(baselib_strconv.o) 中的 wxMBConv_iconv::GetMBNulLen() const wxMBConv_iconv::WC2MB(char*, wchar_t const*, unsigned long) constin libwx_base_carbonud-2.8.a(baselib_strconv.o) wxMBConv_iconv::WC2MB(char*, wchar_t const*, unsigned long) constin libwx_base_carbonud-2.8.a(baselib_strconv.o) wxMBConv_iconv::MB2WC(wchar_t*, char const*, unsigned long) constin libwx_base_carbonud-2.8.a(baselib_strconv.o) wxMBConv_iconv::MB2WC(wchar_t*, char const*, unsigned long) constin libwx_base_carbonud-2.8.a(baselib_strconv.o) libwx_base_carbonud-2.8.a(baselib_strconv.o) 中的 wxMBConv_iconv::wxMBConv_iconv(wchar_t const*) libwx_base_carbonud-2.8.a(baselib_strconv.o) 中的 wxMBConv_iconv::wxMBConv_iconv(wchar_t const*) “_libiconv_close”,引用自: libwx_base_carbonud-2.8.a(baselib_strconv.o)中的wxMBConv_iconv::~wxMBConv_iconv() libwx_base_carbonud-2.8.a(baselib_strconv.o)中的wxMBConv_iconv::~wxMBConv_iconv() libwx_base_carbonud-2.8.a(baselib_strconv.o)中的wxMBConv_iconv::~wxMBConv_iconv() libwx_base_carbonud-2.8.a(baselib_strconv.o)中的wxMBConv_iconv::~wxMBConv_iconv() libwx_base_carbonud-2.8.a(baselib_strconv.o)中的wxMBConv_iconv::~wxMBConv_iconv() libwx_base_carbonud-2.8.a(baselib_strconv.o)中的wxMBConv_iconv::~wxMBConv_iconv() ld:未找到符号 Collect2: ld 返回 1 退出状态

OS: MAC X 10.7.0

The Mac OS X install an older version of wxMac(wxMac-2.8.8.1) in /usr, but I install a newer one(wxMac-2.8.12.0) in /usr/local. To install it, I compile the new one with the flag:

arch_flags="-arch i386"
./configure CFLAGS="$arch_flags" CXXFLAGS="$arch_flags" CPPFLAGS="$arch_flags" LDFLAGS="$arch_flags" OBJCFLAGS="$arch_flags" OBJCXXFLAGS="$arch_flags" --enable-unicode --enable-debug --disable-shared

Then I write a simple program(hello2.cpp) to test it:

#include "wx/wx.h"

class HelloWorldApp : public wxApp
{
public:
    virtual bool OnInit();
private:
    wxButton *button;
};


IMPLEMENT_APP(HelloWorldApp)

bool HelloWorldApp::OnInit()
{
    wxFrame *frame = new wxFrame((wxFrame*) NULL, -1, _T("Hello wxWidgets World"));
    frame->CreateStatusBar();
    frame->SetStatusText(_T("Hello World"));
    button = new wxButton((wxFrame *)frame, -2, _T("123"));
    frame->Show(TRUE);
    SetTopWindow(frame);

    return true;
}

I compile this test program in the command line with the flag:

g++ hello2.cpp /usr/local/bin/wx-config --cxxflags --libs -o hello2

But I receive some warnings and errors. I am a newbie in Mac programming, so I don't know the reason. I just have to say: help!

Here is the result of compiling:

ld: warning: in /usr/local/lib/libiconv.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols:
"_libiconv_open", referenced from:
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
"_libiconv", referenced from:
wxMBConv_iconv::GetMBNulLen() const in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::WC2MB(char*, wchar_t const*, unsigned long) constin libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::WC2MB(char*, wchar_t const*, unsigned long) constin libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::MB2WC(wchar_t*, char const*, unsigned long) constin libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::MB2WC(wchar_t*, char const*, unsigned long) constin libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
"_libiconv_close", referenced from:
wxMBConv_iconv::~wxMBConv_iconv()in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::~wxMBConv_iconv()in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::~wxMBConv_iconv()in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::~wxMBConv_iconv()in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::~wxMBConv_iconv()in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::~wxMBConv_iconv()in libwx_base_carbonud-2.8.a(baselib_strconv.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status

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

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

发布评论

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

评论(1

屋顶上的小猫咪 2024-12-13 19:48:52

我卸载了wxMac-2.8.12。
我安装了 wxWidgets-2.9.2(./configure --enable-unicode --enable-debug --disable-shared)

我用 g++ hello2.cpp `/usr/local/bin/wx-config -- 编译测试程序再次 cxxflags --libs` -o hello2 。只有一个警告:

ld: warning: in /System/Library/Frameworks//QuickTime.framework/QuickTime, 文件中缺少所需的架构 x86_64

我认为没关系。

I uninstall wxMac-2.8.12.
I installl wxWidgets-2.9.2(./configure --enable-unicode --enable-debug --disable-shared)

I compile the test program with g++ hello2.cpp `/usr/local/bin/wx-config --cxxflags --libs` -o hello2 again. There only one warning:

ld: warning: in /System/Library/Frameworks//QuickTime.framework/QuickTime, missing required architecture x86_64 in file

I think that's OK.

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