Lion下编译WxWidgets

看了下WxWidgets的官方文档,看来它对Mac的支持还不是很好,所以问题还是蛮多的。

先下的最新的2.9,结果解压出来差一个文件,错误:

cannot find sources (wx-config.in)

看到这个,我翻了下目录,还真没这个文件,所以暂时放下这个版本,然后搞2.8。

这个倒是简单,解压之后,在docs/cocoa下面有install文档,照着做就行了。

不过在lion下面可能会有这两个问题:

1.

./src/common/dynlib.cpp:48:
./include/wx/mac/carbon/private.h:1459: error: ‘Cursor’ does not name a type
./include/wx/mac/carbon/private.h:1488: error: ‘ClassicCursor’ does not name a type

这个问题的答案就是lion去掉了一些过去使用的API,所以需要让系统link更早的Library就好了,解决办法是在configure的时候加入命令行:

--with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.6

2.第二个错误来自官方的文档说明,应该和平台有关系,看官方的解释:

Building on Snow Leopard for Snow Leopard

When trying to build wx under 10.6 you might - on certain machines - end up with errors like this:

./src/common/intl.cpp: In static member function ‘static int wxLocale::GetSystemLanguage()’:../src/common/intl.cpp:2060: error: ‘smScriptLang’ was not declared in this scope../src/common/intl.cpp:2060: error: ‘GetScriptVariable’ was not declared in this scope../src/common/intl.cpp:2061: warning: ‘GetScriptManagerVariable’ is deprecated (declared at /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Script.h:993)../src/common/intl.cpp:2061:warning:‘GetScriptManagerVariable’ is deprecated(declared at /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Script.h:993)make: *** [baselib_intl.o] Error 1

The reason is that the default compiler on 10.6 is gcc 4.2, and if you are on a Core 2 Duo which is 64-bit capable, you end up compiling Carbon-only 2.8 for 64 bits which fails, due to the lack of 64-bit Carbon support. If you want 64-bit wxWidgets on OS X you'll need 2.9+ and configure -with-osx_cocoa - see below; but remember that 2.9 is not an official, stable release and wxOSX/Cocoa is not yet complete.

So, to compile with 2.8 on a 64-bit Mac, you have to explicitly indicate the architectures you want:

arch_flags="-arch i386"../configure CFLAGS="$arch_flags" CXXFLAGS="$arch_flags" CPPFLAGS="$arch_flags" LDFLAGS="$arch_flags" OBJCFLAGS="$arch_flags" OBJCXXFLAGS="$arch_flags"

This makes the library and samples build nicely for Intel 32-bit targets, and you can also add -arch ppc to the arch_flags so that you can build universal binaries.

因此,我最后的配置命令行是:

../configure --enable-unicode --enable-debug --disable-shared --with-osx_cocoa --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.6 cflags="-arch i386" CXXFLAGS="-arch i386" CPPFLAGS="-arch i386" LDFLAGS="-arch i386" OBJCFLAGS="-arch i386" OBJCXXFLAGS="-arch i386"

最后配置完成,使用make编译。

进入sample目录编译两个小demo,截图:

ae9ec05069cc220984352444

再来一个运行时候的样子:

7cc657336c431c931b4cff7e

转载自 http://hi.baidu.com/dbfr2011818/item/d26f6820dc80e08c6f2cc30e

发布者

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注