wxWidgets-2.8.9在VC++ 2005 环境下的安装与配置
2. 编译wxWidgets。
打开Visual Studio 2005 Command Prompt命令行环境,进入D:"wxWidgets-2.8.9"build"msw目录,找到config.vc并用文本编辑器打开。3. 在vc++环境中设置wxWidgets的头文件和库文件目录
这里要修改一些选项,选项的解释如下
SHARE: 编译产生的wxWidgets库是静态库还是动态库
UNICODE: 是否支持unicode
BUILD: 编译产生的库是用于debug或release
分别编译两套静态库和两套动态库
SHARE = 0 UNICODE = 1 BUILD = debug
SHARE = 0 UNICODE = 1 BUILD = release
SHARE = 1 UNICODE = 1 BUILD = debug
SHARE = 1 UNICODE = 1 BUILD = release
按照上面修改了config.vc后, 分别执行四次nmake -f makefile.vc
编译完成后会在build"msw目录下产生四个临时文件夹vc_mswu vc_mswud vc_mswuddll vc_mswudll,而编译产生的.lib和.dll文件则分别放在lib"vc_lib和lib"vc_dll下。
打开VC++菜单Tools->Options...->Projects and Solutions->VC++ Directories添加如下内容:
Include files: D:"wxWidgets-2.8.9"include
D:"wxWidgets-2.8.9"include"msvc
Library files: D:"wxWidgets-2.8.9"lib"vc_lib
4. 测试
myWxApp.h文件
#ifndef MYWXAPP_H
#define MYWXAPP_H
#include <wx/wx.h>
class myWxApp: public wxApp
{
public:
myWxApp(void);
~myWxApp(void);
virtual bool OnInit();
};
DECLARE_APP(myWxApp)
#endif
myWxApp.cpp文件
#include "myWxApp.h"
IMPLEMENT_APP(myWxApp)
bool myWxApp::OnInit()
{
wxFrame *frame = new wxFrame((wxFrame*)NULL, -1,
wxT("wxWidgets Application"), wxPoint(100,70), wxSize(640,480));
frame->CreateStatusBar(2);
frame->SetStatusText(wxT("Hello World"));
frame->Show(TRUE);
SetTopWindow(frame);
return true;
}
在运行Debug和Release版本前配置Configuration Properties如下
Debug:
Configuration Properties"C/C++"Preprocessor"Preprocessor Definitions:
WIN32;__WXMSW__;_WINDOWS;_DEBUG;__WXDEBUG__
Configuration Properties"C/C++"Code Generation"Runtime Library:
Multi-threaded Debug(/MTd)
Configuration Properties"Linker"Input"Additional Dependencies:
comctl32.lib rpcrt4.lib
Configuration Properties"Linker"Debugging"Generate Debug Info:
Yes(/DEBUG)
Release:
Configuration Properties"C/C++"Preprocessor"Preprocessor Definitions:
WIN32;__WXMSW__;_WINDOWS
Configuration Properties"C/C++"Code Generation"Runtime Library:
Multi-threaded Debug(/MT)
Configuration Properties"Linker"Input"Additional Dependencies:
comctl32.lib rpcrt4.lib
配置
Debug配置
添加预处理
WIN32
_DEBUG
__WXMSW__
__WXDEBUG__
_WINDOWS
NOPCH
添加依赖项
wxbase28d.lib
wxmsw28d_core.lib
winmm.lib
comctl32.lib
rpcrt4.lib
wsock32.lib
oleacc.lib
Release配置
添加预处理
WIN32
_WINDOWS
NDEBUG
添加依赖项
wxbase28.lib
wxmsw28_core.lib
winmm.lib
comctl32.lib
rpcrt4.lib
wsock32.lib
oleacc.lib
Unicode Debug配置
WIN32
_DEBUG
__WXMSW__
__WXDEBUG__
_WINDOWS
NOPCH
添加依赖项
wxbase28ud.lib
wxmsw28ud_core.lib
winmm.lib
comctl32.lib
rpcrt4.lib
wsock32.lib
oleacc.lib
Unicode Release配置
WIN32
NDEBUG
_WINDOWS
添加依赖项
wxbase28u.lib
wxmsw28u_core.lib
winmm.lib
comctl32.lib
rpcrt4.lib
wsock32.liboleacc.lib
使用VC9编译wxWidgets,在wxWidgets的”build/msw/“使用如下批处理命令:
rem 设置vs的环境变量
set oldpath=%path%
set path="C:"Program Files"Microsoft Visual Studio 9.0"Common7"Tools";%path%
call vsvars32.bat
REM ~ nmake -f makefile.vc BUILD=debug SHARED=1 MONOLITHIC=1 UNICODE=1 clean
nmake -f makefile.vc BUILD=debug SHARED=0 MONOLITHIC=0 UNICODE=1
REM ~ nmake -f makefile.vc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1 clean
nmake -f makefile.vc BUILD=release SHARED=0 MONOLITHIC=0 UNICODE=1
REM ~ nmake -f makefile.vc BUILD=debug SHARED=0 MONOLITHIC=0 UNICODE=1 clean
nmake -f makefile.vc BUILD=debug SHARED=1 MONOLITHIC=0 UNICODE=1
REM ~ nmake -f makefile.vc BUILD=release SHARED=0 MONOLITHIC=0 UNICODE=1 clean
nmake -f makefile.vc BUILD=release SHARED=1 MONOLITHIC=0 UNICODE=1
REM ~ nmake -f makefile.vc BUILD=debug SHARED=1 MONOLITHIC=1 UNICODE=1 clean
nmake -f makefile.vc BUILD=debug SHARED=0 MONOLITHIC=1 UNICODE=1
REM ~ nmake -f makefile.vc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1 clean
nmake -f makefile.vc BUILD=release SHARED=0 MONOLITHIC=1 UNICODE=1
REM ~ nmake -f makefile.vc BUILD=debug SHARED=0 MONOLITHIC=0 UNICODE=1 clean
nmake -f makefile.vc BUILD=debug SHARED=1 MONOLITHIC=1 UNICODE=1
REM ~ nmake -f makefile.vc BUILD=release SHARED=0 MONOLITHIC=0 UNICODE=1 clean
nmake -f makefile.vc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1
set path=%oldpath%
pause