﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-猫窟</title><link>http://www.cppblog.com/moogle/</link><description>a little mog hut</description><language>zh-cn</language><lastBuildDate>Sat, 30 May 2026 05:43:52 GMT</lastBuildDate><pubDate>Sat, 30 May 2026 05:43:52 GMT</pubDate><ttl>60</ttl><item><title>用wxWidget开发炒股模拟器（一）--构建VC+wxWidget开发环境</title><link>http://www.cppblog.com/moogle/archive/2014/06/05/207201.html</link><dc:creator>猫古力</dc:creator><author>猫古力</author><pubDate>Thu, 05 Jun 2014 15:44:00 GMT</pubDate><guid>http://www.cppblog.com/moogle/archive/2014/06/05/207201.html</guid><wfw:comment>http://www.cppblog.com/moogle/comments/207201.html</wfw:comment><comments>http://www.cppblog.com/moogle/archive/2014/06/05/207201.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/moogle/comments/commentRss/207201.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/moogle/services/trackbacks/207201.html</trackback:ping><description><![CDATA[<div>    <div id="content" mod-cs-content="" text-content=""  clearfix"=""> <p>最近要给自己做一个小小的模拟炒股软件，在网上翻了很多模拟软件，都不能满足我的需要。我主要是用来测试和跟踪各种炒股策略的，在这方面，没有一个模拟软件提供这种功能。GNOME上似乎有一个，但是没法做A股，不得已，我只能自己开发。<br /><br /><br />我的情况是09年之前，我是一个程序猿，C++是我用的最多的语言，不过自己水平自己知道，不是一块编程的料，C++用的最多，也只是稍微有点熟练而已。09年之后，我进入了金融行业，再也没有碰过编程。所以几乎都忘光了。现在需要用到，所以只能重新拾起来。<br /><br /><br />为什么选择wxWidgets，因为考虑到以后可能要跨平台，比如在苹果机上面用，比较了比较复杂的QT和wxW，最后还是选择了和MFC类似的wx。<br /><br /><br />好了，废话少说，开始干活。<br /><br /><br />今天的任务就是搭建一个开发环境，重新摸起扔了6年的东西。<br /><br /><br />我的记录基本上是流水账，为了和大家分享，也没有什么特定的格式。请看贴的朋友多包涵哈！<br /><br /><br />OS：windows 7 pro sp1 <br />IDE：VS2010 ...汗，都已经到2010啦~~~<br />-----------------------------------------------------------------------------------------------<br /><br />&gt;&gt;下载wxWidgets 3.0，解压<br /> &nbsp; &nbsp; 安装visual studio 2010...光装个VC++就用掉了4个G的空间。<br /><br /><br /><br />&gt;&gt;  解压后看install.txt，然后进入/build/msw 目录，找到wx_vc10.sln，打开后按F6  build。这里出来的基本上是32位debug版本。编译好的东西都在 build/msw/vc_mswud &nbsp;看名字是unicode  debug版本。<br /><br /><br />&gt;&gt; 构建我的项目<br />新建solution, VC++的空项目，名称就是stocktrack，在构建项目的时候不要勾&#8220;为项目创建目录&#8221;，<br /><br />我的项目目录在e:\02_DEV\01_CPP\stocktrack\build\<br />我习惯把项目文件(solution, proj )放在build目录<br />源文件放在src目录</p><p><img alt="" src="http://www.cppblog.com/images/cppblog_com/moogle/dir.png" height="177" width="362" /><br /></p><p>文件的命名规范的话，就按照我项目名称英文单词的第一个英文字母，叫stXXX.app, stXXX.h</p><p><br /></p><p>&gt;&gt;hello world程序<br />在src的根目录新建两个文件 stApp.h , stApp.cpp <br />添加到solution 里面。<br /><img src="http://imgsrc.baidu.com/forum/w%3D580/sign=0588f541a2ec08fa260013af69ef3d4d/349b033b5bb5c9eae745521dd739b6003bf3b39e.jpg" alt="" height="234" width="238" /><br />然后把wx的头文件和自己项目的头文件目录包含进来。因为我一开始做，所以src中既放头文件又放源文件。<br /><br /></p><p><br /></p><p>&gt;&gt; 在stApp.h中拷贝tutorial第一课hello world里面的两行<br />// wxWidgets "Hello world" Program<br />// For compilers that support precompilation, includes "wx/wx.h".<br />#include &lt;wx/wxprec.h&gt;<br />#ifndef WX_PRECOMP<br />#include &lt;wx/wx.h&gt;<br />#endif<br /><br /><br />在stApp.cpp把剩余的都输入。东西太多，我就不一一输入了。<br /><br /><br /><br />编译一下。。。。。立马出错<br />&#8220;错 误 &nbsp; &nbsp;1 &nbsp; &nbsp;error C1083: 无法打开包括文件:&#8220;wx/wxprec.h&#8221;: No such file or directory  &nbsp; &nbsp;e:\02_dev\01_cpp\stocktrack\src\stapp.h &nbsp; &nbsp;3 &nbsp; &nbsp;1 &nbsp; &nbsp;stocktrack&#8221;<br /><br /><br />问题在我包含目录多包了一层！（唉，中文的vs实在看不惯啊）<br /><img src="http://www.cppblog.com/images/cppblog_com/moogle/2.png" alt="" border="0" height="412" width="444" /><br /></p><p><br /></p><p>再编译一下，还出错<br />错误 &nbsp; &nbsp;1 &nbsp; &nbsp;error C1083: 无法打开包括文件:&#8220;wx/setup.h&#8221;: No such file  or directory &nbsp; &nbsp;e:\02_dev\01_cpp\wxwidgets-3.0.0\include\wx\platform.h   &nbsp; 189 &nbsp; &nbsp;1 &nbsp; &nbsp;stocktrack<br /><br />找不到这个文件。。。。我用everything搜索了一下这个文件，原来是在include下面的msvc中的。看来还要把这个目录也包含进去。<br /><br /><br />在编译，又出错<br /><br />错 误 &nbsp; &nbsp;1 &nbsp; &nbsp;error C1083: 无法打开包括文件:&#8220;../../../lib/vc_lib/mswd/wx/setup.h&#8221;:  No such file or directory &nbsp; &nbsp; e:\02_dev\01_cpp\wxwidgets-3.0.0\include\msvc\wx\setup.h &nbsp; &nbsp;119 &nbsp; &nbsp;1 &nbsp; &nbsp; stocktrack<br />仔细看一下，这个文件是在 msvc\wx\setup.h中出错的，那么按照路径没有什么问题。恐怕问题出在mswd上面，我们一般都是mswud，而他是mswd。因此问题可能出在字符集上面<br /><br /><br />在项目属性里面把字符集设置为unicode即可解决这个问题。<br />现在已经是全球化的时代，要一开始就培养使用unicode的习惯。</p><p><br /></p><p>另外这里吐槽一下，VS2010好慢啊。。。可能是楼主我的机器老了，3年前的台式机。。4年前的笔记本。。。另外每个类后面都要加上分号，这难道是新标准？<br /><br /><br />我还是删了2010，换回2005吧，这个以前用了好几年的IDE，应该会更顺手点。</p><p><br /></p><p><br /></p><p>换回了VS2005，重新编译wx，重新编译我的代码，语法问题全部解决了。<br />出现了这个问题，终于到了链接期问题了。<br /><br />LINK : fatal error LNK1104: cannot open file 'wxbase30ud.lib'<br /><br /><br />因此要在项目的property页把Linker(链接器)里面的库路径加上wx的lib路径.<br /><img alt="" src="http://www.cppblog.com/images/cppblog_com/moogle/3.png" height="593" width="760" /><br /><br /><br /></p><p>呜呼,终于没有errro了</p><p><br /><br />按F5启动Debug版程序，还是有点小小的兴奋的。<br /><br /><br /></p> </div></div><img src ="http://www.cppblog.com/moogle/aggbug/207201.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/moogle/" target="_blank">猫古力</a> 2014-06-05 23:44 <a href="http://www.cppblog.com/moogle/archive/2014/06/05/207201.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>