由于最近在学习《Ray Tracing from thee Ground Up》,书中的示例程序是使用wxWidgets这个跨平台图形API写的,故学习了下,记录下来以便复习。
关于wxWidgets的相关消息可以参见官方网站 http://www.wxwidgets.org/查看更多信息。
(1)编译源文件
下载Mac OSX版本的源文件,用Xcode打开build/osx/wxcocoa.xcodeproj文件,点击编译,等待编译过程。
编译过程中出现错误“cannot initialize a variable of type ‘WebBackForwardList *‘ with an rvalue of type ‘WKBackForwardList *‘ WebBackForwardList* history = [m_webView backForwardList];”。查找相关资料后,见到下面这段话:
This is a reported bug with wxWidgets-3.0.2 that only occurs on Yosemite. The reason for this bug is that Apple updated it’s Headers for Webkit. Fortunately, the old headers still exist in a header file called WebkitLegacy.h
. This bug, however is fixed in the 3.0.3 version of the library, but isn’t still available for download (you can still get that by cloning the wxwidgets repo). Currently to fix this, all you need to edit a file src/osx/webview_webkit.mm
and look for line 31.
可见这是在Yosemite系统的上的一个BUG,因为苹果公司更新了WebKit的头文件,在src/osx/webview_webkit.mm的31行找到如下代码:
#include <WebKit/WebKit.h>
The above is the line 31 of the source file wxWidgets-3.0.2/src/osx/webview_webkit.mm
. All you need to do is to replace that line with the following alternative.
将这段注释掉,替换成下面这段代码:
#include <WebKit/WebKitLegacy.h>
详情参见:http://goharsha.com/blog/compiling-wxwidgets-3-0-2-mac-os-x-yosemite/
继续编译,知道最后成功完成。
(2) Xcode上创建新项目
具体操作参考:https://wiki.wxwidgets.org/Creating_Xcode_projects_for_wxWidgets_applications
(图片资源来自于网络,如有不妥请联系笔者删除)
设置完后会出现编译错误,如下:
Info_cocoa.plist 改为 “Info.plist”加入工程目录文件夹XXXTests中。