LIBRARY_PATH :C:\MinGW\lib
C_INCLUDE_PATH :C:\MinGW\include
CPLUS_INCLUDE_PATH :C:\MinGW\include\c++\3.2.3;C:\MinGW\include\c++\3.2.3\mingw32;
C:\MinGW\include\c++\3.2.3\backward;C:\MinGW\include
这样,直接在命令行里就可以调用编译的指令/程序了。
好了,开始编译wxwidgets了。
wx支持两种方法设置变异的文件属性,一种是在win的命令行cmd.exe下使用makefile直接设置编译;另一种,是在msys下用configure来设置,然后编译。记得,前一种方法可以让用户拥有多个wx的库,比如同是拥有debug和release版本,使用的时候只要在后边加上属性就可以区分了(过会详述);后者,则在编译自己的程序的时候比较方便,不用谢属性来区分版本,编译之后得到的lib可以安装,成为默认的库,当然,如果以后还想用别的功能的库了,就要在configure一次了。(声明:这个我记得第一次安装wx的时候在那里看过,但记得不清楚了,也没再找到这文章,所以不保证什么。我使用的是makefile来装。我对linux也使一知半解的,所以如有不对的地方,还请大虾不吝赐教。)
命令如下:
cd E:\CPPtools\wxWidgets\build\msw (安装路径E:\CPPtools\wxWidgets)
mingw32-make -f makefile.gcc BUILD=debug UNICODE=1
好了,等着吧,大约半小时到一小时,需要700多m的空间,就可以编译好了。
这里要注意,因为我之前先安装了bcbx,而bcbx(bcb5.6)的make程序叫make,所以,mingw(gcc3)的make程序现在叫mingw32-make了,你可以改一下名字,也可以这么用,但别混了,这可不是一个编译器。对了,另外,在eclipse+cdt里使用mingw32-make比较麻烦,也不方便,特别是你还有一个make的时候(这两个可都在path里了,eclipse搞不定了),你可以写个bat文件,定义临时的path路径,来屏蔽掉bcb的路径,然后拷贝一个mingw32-make改名称make就成了。
makefile.gcc后边的属性项目在install.txt文件的后边写着了,帅哥用过的也就是那么几个常用的,我这里大概说一下。
Basic options
-------------
BUILD=debug
编译调试版本,因为加入了调试信息,所以文件比较大。
Builds debug version of the library (default is 'release'). This affects
name of the library ('d' is appended), __WXDEBUG__ is defined and debug
information compiled into object files and the executable.
SHARED=0
生成动态链接库的版本。动态链接库是很有用的,特别是使用LGPL的开发库的时候,都要变成动态库,才可以商业用。
Build static libraries instead of DLLs. By default, DLLs are built
(SHARED=1).
UNICODE=1
本人是中国人,自然要选这个,就是学的时候要注意的东西多一写,但总比以后不习惯强。
To build Unicode versions of the libraries, add UNICODE=1 to make invocation
(default is UNICODE=0). If you want to be able to use Unicode version on
Windows9x, you will need to set MSLU=1 as well.
This option affect name of the library ('u' is appended) and the directory
where the library and setup.h are store (ditto).
WXUNIV=1
就是不让wx使用native的样式,使用统一的样式——跟人感觉不好看,但是后项开发的时候会比较方便,以为不用考虑各种gui元素的定位引起问题了。
Build wxUniversal instead of native wxMSW (see
http://www.wxwidgets.org/wxuniv.htm for more information).
Advanced options
----------------
MONOLITHIC=1
把所有的库都变在一个文件中。
Starting with version 2.5.1, wxWidgets has the ability to be built as
several smaller libraries instead of single big one as used to be the case
in 2.4 and older versions. This is called "multilib build" and is the
default behaviour of makefiles. You can still build single library
("monolithic build") by setting MONOLITHIC variable to 1.
USE_GUI=0
不用gui模式,编写命令行的程序。
Disable building GUI parts of the library, build only wxBase components used
by console applications. Note that if you leave USE_GUI=1 then both wxBase
and GUI libraries are built. If you are building monolithic library, then
you should set wxUSE_GUI to 1 in setup.h.
USE_OPENGL=1
自带opengl支持
Build wxmsw25_gl.lib library with OpenGL integration class wxGLCanvas.
You must also modify your setup.h to #define wxUSE_GLCANVAS 1. Note that
OpenGL library is always built as additional library, even in monolithic
build!
USE_ODBC=1
自带odbc支持
Build two additional libraries in multilib mode, one with database
classes and one with wxGrid database support. You must
#define wxUSE_ODBC 1 in setup.h
USE_HTML=0
不用html库
Do not build wxHTML library. If MONOLITHIC=1, then you must also
#define wxUSE_HTML 1 in setup.h.
USE_XRC=0
不用xrc库。xrc是wx为了避免在不同的gui系统上程序元素之间的配合特别是定位的问题而提供的基于XML的用户界面标记语言,通过定义不同系统上不同的xml样式,来解决问题,有点类似于换肤。和xul还有xaml有点类似。
Do not build XRC resources library. If MONOLITHIC=1, then you must also
#define wxUSE_HTML 1 in setup.h.
RUNTIME_LIBS=static
不太明白。
Links static version of C and C++ runtime libraries into the executable, so
that the program does not depend on DLLs provided with the compiler (e.g.
Visual C++'s msvcrt.dll or Borland's cc3250mt.dll).
Caution: Do not use static runtime libraries when building DLL (SHARED=1)!
MSLU=1
不是像找麻烦开发win98程序的人就不用管了。
Enables MSLU (Microsoft Layer for Unicode). This setting makes sense only if
used together with UNICODE=1. If you want to be able to use Unicode version
on Windows9x, you will need MSLU (Microsoft Layer for Unicode) runtime DLL
and import lib. The former can be downloaded from Microsoft, the latter is
part of the latest Platform SDK from Microsoft (see msdn.microsoft.com for
details). An alternative implementation of import library can be downloaded
from http://libunicows.sourceforge.net - unlike the official one, this one
works with other compilers and does not require 300+ MB Platform SDK update.
DEBUG_FLAG=0
DEBUG_FLAG=1
If set to 1, define __WXDEBUG__ symbol, append 'd' to library name and do
sanity checks at runtime. If set to 0, don't do it. By default, this is
governed by BUILD option (if 'debug', DEBUG_FLAG=1, if 'release' it is 0),
but it is sometimes desirable to modify default behaviour and e.g. define
__WXDEBUG__ even in release builds.
DEBUG_INFO=0
DEBUG_INFO=1
Same as DEBUG_FLAG in behaviour, this option affects whether debugging
information is included in the executable or not.
VENDOR=<your company name>
Set this to a short string identifying your company if you are planning to
distribute wxWidgets DLLs with your application. Default value is 'custom'.
This string is included as part of DLL name. wxWidgets DLLs contain compiler
name, version information and vendor name in them. For example
wxmsw250_core_bcc_custom.dll is one of DLLs build using Borland C++ with
default settings. If you set VENDOR=mycorp, the name will change to
wxmsw250_core_bcc_mycorp.dll.
CFG=<configuration name>
Sets configuration name so that you can have multiple wxWidgets builds with
different setup.h settings coexisting in same tree. See "Object and library
directories" below for more information.
后边的几个我也不太明白,对于菜鸟来说,即便去看关于他们的资料也用不上,什么时候用到了,什么时候再说吧。
编译好之后,会在E:\CPPtools\wxWidgets\build\msw\gcc_mswud 生成编译的中间文件,可以删除。
在E:\CPPtools\wxWidgets\lib\gcc_lib 里找到需要的.a文件,这就是我们的编译成果351m大小。
呵呵,好了,要是完全按照我这个做的话,就没问题了,可以编译samples玩玩了。
cd E:\CPPtools\wxWidgets\samples\minimal
mingw32-make -f makefile.gcc BUILD=debug UNICODE=1
编译完成之后,就会在E:\CPPtools\wxWidgets\samples\minimal\gcc_mswud 下生成一个minimal.exe和两个.o文件,两个.o文件要使不用的话,就可以删掉了——我还不知道怎么让机器自动删除中间文件,由大虾知道的话请告知。
当然,也可以在samples目录下便直接使用这个目录下的makefile来编译所有的sample,但要注意,有些samples演示的时特殊设置下的功能,所以学要编译使用此种属性的wx库文件。
btw,不知道是因为make的问题,还是makefile的问题,发现编译过程一旦遇到错误就会自动终止,而不是跳过,这样很麻烦的,不能智能化编译真的很累。不知道cmake等等程序可不可以解决此等问题。现在好像make工具和makefile生成工具有很多,真是够叫人头痛的。由大虾知道的话请指教。
好了,就这么多了吧,我写的够详细的了,好累呀。。。
呵呵,以后还要大量使用各种开放库,真是前路漫漫亚。
本文地址:http://com.8s8s.com/it/it23591.htm