如何使用VS2005编译

 

这篇文章帮助你用用Microsoft C++编译器编译OpenWenGo

需求:

VS2005 Express

Platform SDK

DirectX SDK

其他WengoPhone的依赖软件:Python,Scons,Qt,Boost

XP Sp2补丁

C:空间大于4G

D:空间足够多

Microsoft 开发工具和SDK的安装

VS2005默认安装在C: (我的装在D:)

Platform SDK

VS2005不包括编译所需的头文件和库文件.这些文件包含在Platform SDK 中. Platform SDK可以在这里下载here.

把Platform SDK安装在D:/Program Files/Platform SDK,编辑vs32var.bat脚本文件(位于FIXME中),将以下路径加入系统路径变量中(INCLUDE):

  • D:/Program Files/Platform SDK/include
  • D:/Program Files/Platform SDK/include/atl

LIB:

·    D:/Program Files/Platform SDK/lib

Platform SDK 不包括DirectX的头文件和库文件.它们包含在DSK中. DirectX SDK可以在这里下载here.你可以将其安装在D:/ProguamFiles/DirectX SDK

编辑vs32var.bat脚本文件(位于FIXME中)

加入定义头文件的路径:

·    D:/Program Files/DirectX SDK/include;

LIB:

  • D:/Program Files/DirectX SDK/lib;

此外,你可以编辑setenv.bat脚本文件假如以上路径,详细请参考附录

编译工具(Build tools)

下载Python2.4.3à here.  

下载PythonWindows的扩展à here(不要改变安装路径)

下载Scons0.96à here.

编辑PATH环境变量把scons.bat文件包含其中,这个文件在Python的安装目录.

需要的库:

QT

下载QT4.1.2à from trolltech.

解压到:D:/QT/4.1.2

下载QT作为vs2005的补丁this patch

应用补丁:在QT的目录解压acs4qt412p1.zip

进入QT的目录运行installpatch41.bat

运行"qconfigure.bat msvc2005".此时将创建makefile并且编译整个QT库.

加入PATH环境变量: C:/Qt/4.1.2/bin;C:/Program Files/Python24

创建环境变量QTDIR=D:/QT/4.1.2.

Boost

下载Boostà here.

下载jamà here.

运行boost_1_33_1.exe抽取原文件到D:/boost_1_33_1目录

解压缩boost-jam-3.1.13-1-ntx86.zip 再把bjam.exe复制到D:/boost_1_33_1

转到Boost的原文件目录运行

·  bjam "-sTOOLS=vc-8_0" “—prefix=d:/” install

设置环境变量

安装WengoPhone

检查源代码文件(略)

改写Boost的库名

请使用以下步骤:

编辑wengoscons/lib/boost/Sconscript 将库名字由boost-xx-vc71-* 改为 boost-xx-vc80-*:

·                if WengoCCMSVC():
·                         libs += [
·                                 'libboost_thread-vc80-mt.lib',
·                                 'libboost_serialization-vc80-mt.lib',
·                                 'libboost_signals-vc80-mt.lib',
·                                 'libboost_regex-vc80-mt.lib',
·                                 'libboost_program_options-vc80-mt.lib',
·                         ]

出现的错误:在编译DLL时找不到Boost库

说明: Boost库名包含着编译器的版本信息,当使用VS2005编译Boost时,原来的VC71已经被VC80所代替.

首先(First workaround):首先构件libcurl再编辑它的脚本文件(SConscript)

方法:

打开VS2005的命令模式

·                > d:/
·                > cd /wengophone
·                > scons mode=release-symbols owcurl
·         编译成功后,编辑libs/curl/Sconscript将Include_path = [ ‘include’, ‘lib’ ] 改为Include_path = [ ‘include’ ] 

出现的错误:在编译main.cpp时xiobase的头文件_SH_DENYNO未定义

说明:share.h包含在libs/curl/lib中,正好和编译main.cpp时的内建文件share.h冲突.

其次(Second workaround:):从netlib.cpp中删除多余的声明

方法:

编辑wifo/netlib/src/netlib.cpp

删除或者注释掉以下声明(它们已经在wininet.h中有定义).

·                typedef struct {
·                         BOOL(* IsResolvable) (LPSTR lpszHost);
·                         DWORD(* GetIPAddress) (LPSTR lpszIPAddress, LPDWORD lpdwIPAddressSize);
·                         BOOL(* ResolveHostName) (LPSTR lpszHostName, LPSTR lpszIPAddress, LPDWORD lpdwIPAddressSize);
·                         void(* IsInNet) (LPSTR lpszIPAddress, LPSTR lpszDest, LPSTR lpszMask);
·                } AutoProxyHelperVtbl;
·                 
·                typedef struct {
·                         AutoProxyHelperVtbl * lpVtbl;
·                } AutoProxyHelperFunctions;
·                 
·                typedef struct {
·                         DWORD dwStructSize;
·                         LPSTR lpszScriptBuffer;
·                         DWORD dwScriptBufferSize;
·                } AUTO_PROXY_SCRIPT_BUFFER;
·                 
·                typedef BOOL(CALLBACK * pfnInternetInitializeAutoProxyDll) (
·                         DWORD dwVersion,
·                         LPSTR lpszDownloadedTempFile,
·                         LPSTR lpszMime,
·                         AutoProxyHelperFunctions * lpAutoProxyCallbacks,
·                         AUTO_PROXY_SCRIPT_BUFFER * lpAutoProxyScriptBuffer);
·                 
·                typedef BOOL(CALLBACK * pfnInternetDeInitializeAutoProxyDll) (
·                         LPSTR lpszMime,
·                         DWORD dwReserved);
·                 
·                typedef BOOL(CALLBACK * pfnInternetGetProxyInfo) (
·                         LPCSTR lpszUrl,
·                         DWORD dwUrlLength,
·                         LPSTR lpszUrlHostName,
·                         DWORD dwUrlHostNameLength,
·                         LPSTR * lplpszProxyHostName,
·                         LPDWORD lpdwProxyHostNameLength);
·                 
·                #define PROXY_AUTO_DETECT_TYPE_DNS_A 2
·                #define PROXY_AUTO_DETECT_TYPE_DHCP 1

出现的错误:编译错误,用不同的类型对某些功能2次定义

说明:我认为VS2003的wininet.h不包含所需求的声明,这些声明已经存在.

第三(Third workaround):在链接PhApi是找不到atlthunk.lib库

missing lib atlthunk.lib when linking PhApi

编辑D:/Program Files/Platform SDK/include/atl/atlbase.h

注释掉以下信息

·                /*
·                PVOID __stdcall __AllocStdCallThunk(VOID);
·                VOID  __stdcall __FreeStdCallThunk(PVOID);
·                 
·                #define AllocStdCallThunk() __AllocStdCallThunk()
·                #define FreeStdCallThunk(p) __FreeStdCallThunk(p)
·                 
·                #pragma comment(lib, "atlthunk.lib")
·                */

添加以下定义用来替换:

·  // workaround for not having atlthunk.lib in PSDK or VC++ 2005 Express Edition
·  #define AllocStdCallThunk() HeapAlloc(GetProcessHeap(),0,sizeof(_stdcallthunk))
·  #define FreeStdCallThunk(p) HeapFree(GetProcessHeap(), 0, p)

如果你忘记了这一步将会遇到错误,在重新编译前不要忘记删除预编译头文件vc80.pch(在ow目录中).

出现的错误:编译PhApi.dll时连接错误,找不到atlthunk.lib

说明:atlthunk.lib仅包含在完全安装的VS2005zhong  ,但是如果ATL类没有用与工作环境中,将能够正确编译和连接.

更详细的信息参见:

  • http://forums.microsoft.com/msdn/showpost.aspx?postid=64509&siteid=1
  • http://resources.kairo.at/mozilla/build/make-win-tinderbox-vc8express.html

第四(Fourth workaround):纠正DirectXWebCam头文件

方法:

·  在#include <dshow.h>之前添加#include <tchar.h>
DirectXWebCamDriver.h and DirectXWebCamUtils.h.
两个文件都要改
出现的错误:在echar.h后要包含strsafe.h
说明:MSDN论坛上有一些含糊的说明here.

有两个常见的问题:1)编译unicode和ansi或者vice versa过滤器2)在VS2005已经将Treat wchar_t作为一个内建的数据类型.一定要让这个设置与你的过滤器和基础类库一致.注意:命令模式和图形模式表现出的错误是不同的.

第五(Fifth workaround: GAIM IM Factory

编辑Fifth workaround: GAIM IM Factory libs/imwrapper/src/gaim/GaimIMFactory.cpp

注释掉glib的头文件包含

  • Edit libs/imwrapper/src/gaim/GaimIMFactory.cpp
  • Comment out extern “C” directive around glib includes:

·                // extern “C” {

·                #include "glib.h"

·                #include "gaim/internal.h"

·                #include "gaim/core.h"

·                #include "gaim/eventloop.h"

·                #include "gaim/blist.h"

·                #include "gaim/util.h"

·                #include "gaim/connection.h"

·                #include "gaim/blist.h"

·                #include "gaim/conversation.h"

·                #include "gaim/account.h"

·                #include "gaim/privacy.h"

·

·                // }

出现的问题:D:/Program Files/Microsoft Platform SDK/Include/wspiapi.h(44) : error C2894: templates cannot be declared to have 'C' linkage

说明:Glib头文件包含了一些使用模版的系统头文件,但是外部变量"c"在cplusplus中的定义没有删除. Glib头文件好象已经包含了外部变量"c"

第六(AvatarList? header file order):头文件的顺序

编辑Sixth workaround: AvatarList? header file order

删除#include "AvatarList?.h"中的以下信息

·  * You should have received a copy of the GNU General Public License
·   * along with this program; if not, write to the Free Software
·   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
·   */
·   
·   
·  #include <model/config/Config.h>
·  #include <model/config/ConfigManager.h>
·   
·  #include <util/File.h>
·  #include <util/Path.h>
·   
·  #include "AvatarList.h" // won't compile in vc++ 2005 unless moved down
·   
·  AvatarList::AvatarList() {
·  }

出现的错误: C:/Programmi/Microsoft Visual Studio 8/VC/INCLUDE/swprintf.inl(41) :error C2664: '_vswprintf_c_l' : cannot convert parameter 4 from 'void *' to '_locale_t' Conversion from 'void*' to pointer to non-'void' requires an explicit cast

Win32dep.h中名字的矫正

方法:

编辑: libs/gaim/include/gaim/win32dep.h.

  • Surround function declarations with:

·                #ifdef __cplusplus

·                extern "C" {

·                #endif

·

·                (…)

·                Functions declarations

·                (…)

·

·                #ifdef __cplusplus

·                }

·                #endif

出现的错误:在创建qtwengophone.lib时外部变量wgain_init没有定义

说明:预编译的libgaim已经是一个c的库了

复制库文件(and wchar_t problems)

在最后连接wengophoneng.exe时如果你遇到了连接错误fatal error LNK1169: or more multiply defined symbols found,你应该修改wengophone.py(主scons的编译脚本,在/wengoscons/wengoscons中)

第500行,正确的是:

class CCMSVC:
"""
MSVC (Microsoft Visual C++) compiler support.
"""
def setReleaseModeWithSymbols(self):
self.__setDefaultFlags()
self.__CCFlags += ['/O1', '/MD', '/Zi']
self.__linkFlags += ['/DEBUG', '/NODEFAULTLIB:MSVCRTD.LIB',
'/NODEFAULTLIB:libcpmt.lib']
def __setDefaultFlags(self):
self.__CCFlags = ['/Zm200', '/EHsc', '/GR']
self.__linkFlags = []

主要的修改是self.linkFlags and self.CCFlags

[本说明文档应该做为测试版]

在连接时,你可能遇到更多的和wchar_t有关的错误,以下将帮你解决.

你可能遇到以上提到的和wchar_t有关的问题.试着修改wengophone.py如下(相似)

def __setDefaultFlags(self):
#old line msvc   self.__CCFlags = ['/Zm200', '/EHsc', '/GX', '/GR']
                 self.__CCFlags = ['/Zm200', '/EHsc', '/GR', '/Zc:wchar_t'] # new line
                 self.__linkFlags = []

这可能导致另一个错误:

webcam.lib(DirectXWebcamDriver.obj) : error LNK2019: unresolved external symbol 
"char * __stdcall _com_util::ConvertBSTRToString(wchar_t *)"

为了解决这个问题你应该编辑wifo/phapi/Sconscript so that the occurrence of comsupp becomes comsuppw(据邮件列表中所说这个改变应该在webcam目录,因此是可选的)

if WengoCCMSVC():
        libs += [
            'comsuppw',
        ]

编辑(Compilation)

如何开始:

·    Open:

Start All programs Visual C++ 2005 Express Edition Visual Studio 2005 Command prompt

·    Launch: scons mode=release-symbols qtwengophone

·    Or modify the project file attached below

Other targets (these may or may not work, but it's a starting point)

·    Launch: scons mode=release-symbols qtwengophone-translations

·    Launch: scons mode=release-symbols qtwengophone-nsis-installer-without-pdb

运行WengoPhone NG

Manifest file

从VS2005启动, Manifest file (manifest files have been introduced to circumvent the DLL hell problem),你必须从你的编译目录复制到它的跟目录,否则WengoPhone 将不能加载mscvr80.dll

附录:环境变量

 BOOSTINCLUDEDIR=d:/boost/include/boost-1_33_1
BOOSTLIBDIR=D:/boost/lib
FrameworkSDKDir=C:/Program Files/Microsoft Visual Studio 8/SDK/v2.0
FrameworkVersion=v2.0.50727
INCLUDE=D:/Program Files/Microsoft Platform SDK/Include/atl;D:/Program Files/DirectX SDK/Include;D:/Program Files/Microsoft Platform SDK/Include;C:/Program Files/Microsoft Visual Studio 8/VC/INCLUDE;
LIBPATH=C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727
Path=D:/Program Files/Microsoft Platform SDK/Bin;C:/Program Files/Microsoft Visual Studio 8/Common7/IDE;C:/Program Files/Microsoft Visual Studio 8/VC/BIN;C:/Program Files/Microsoft Visual Studio 8/Common7/Tools;C:/Program Files/Microsoft Visual Studio 8/SDK/v2.0/bin;C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727;C:/Program Files/Microsoft Visual Studio 8/VC/VCPackages;D:/Program Files/DirectX SDK/Utilities/Bin/x86";C:/WINDOWS/system32;C:/WINDOWS;d:/Python24
QTDIR=D:/Qt/4.1.2
QTJAVA=C:/Program Files/QuickTime/QTSystem/QTJava.zip
VCINSTALLDIR=C:/Program Files/Microsoft Visual Studio 8/VC
VS80COMNTOOLS=C:/Program Files/Microsoft Visual Studio 8/Common7/Tools/
VSINSTALLDIR=C:/Program Files/Microsoft Visual Studio 8

以工程文件作为启动点

Attached is a project file that can be used as a starting point for building wengophone integrated into VS2005. It will need to be modified so that all directories point to where you have put the files.

Specifically (but not guaranteed to be all the spots) you will have to point to the proper directories:

Project->Properties->Configuration Properties->NMake->General->Build Command Line:

Project->Properties->Configuration Properties->NMake->General->Rebuild All Command Line:

Project->Properties->Configuration Properties->Debugging->Environment: You may want to remove the debugging flags here.

Tools->Options->Projects and Solutions->VC++ Directories->Win32->Include files: Add the following:

C:/Program Files/Microsoft Platform SDK for Windows Server 2003 R2/Include

C:/Program Files/Microsoft DirectX SDK/Include

Tools->Options->Projects and Solutions->VC++ Directories->Win32->Library files: Add the following:

C:/Program Files/Microsoft Platform SDK for Windows Server 2003 R2/Lib

interesting ML threads ¶

* http://thread.gmane.org/gmane.comp.voip.wengophone.devel/3150/focus=3150

Attachments

  • VCCWengo.vcproj (360.9 kB) -This will need to be modified for your environment., added by lukaso on 12/18/06 20:28:01.

编译boost库-用vc2005编译boost1.33.1
//打开控制台窗口,请使用vs2005在开始菜单中的“Visual Studio Tools->Visual Studio 2005 命令提示”打开控制台,这样vc的的编译环境就设置好了。
//假设boost安装包的解压的目录为{BOOST_SRC}中。
//先编译出bjam.exe,它被用于安装boost库
cd {BOOST_SRC}/tools/build/jam_src
build.bat
//利用编译出的bjam.exe程序编译并安装boost库
cd {BOOST_SRC}
copy {BOOST_SRC}/tools/build/jam_src/bin.ntx86/bjam.exe
//下面的命令的各选项的说明:
//prefix    将boost安装到的路径(生成的头文件和库文件都会放到该路径中)。
//重定义以下变量(利用-s设置):
//VC80_ROOT  vc2005的安装路径,如果未将vc2005安装到默认位置,你必须指定该项。
//TOOLS         使用的编译工具,vc2005对应的是vc-8_0
//PYTHON_ROOT        python的安装目录,如果未将BOOST安装到默认位置,你必须指定该项。
//BUILD         编译结果选项,默认会生成尽可能多的版本,如调试版/发行版,静态库/动态库,单线程/多线程。
bjam "-sVC80_ROOT=D:/Program Files/Microsoft Visual Studio 8/VC" "-sTOOLS=vc-8_0"  "-sPYTHON_ROOT=D:/Program Files/Python24" "--prefix=E:/librarys/boost" install

boost在vc2005中的编译出现codepage警告和DEPRECATED函数的解决近日下载了一个VC2005 Express Edition,用它来编译boost,发现有不少的warning C4819,说代码文件中有cp936无法表示的字符,还有就是vc2005特有的废弃的ANSI函数的错误,虽说不影响编译,但是看着时不时出现的warning总是让人心神不安,还容易掩盖其他的错误,如果是直接用cl编译,只要加上/wd4819 /D_CRT_SECURE_NO_DEPRECATE就可以不显示这两个错误,但是大家都知道boost是使用其特有的boost.build进行编译的,下面我就给出如何修改boost.build来抑制这两个错误的显示

boost.build分为v1和v2两个版本
v1:
修改$(BOOST_ROOT)/tools/build/v1/vc-8_0-tools.jam

flags vc - 8_0 C++ FLAGS :  / Zc:forScope ;
改为

flags vc - 8_0 C++ FLAGS :  / Zc:forScope  / wd4819  / D_CRT_SECURE_NO_DEPRECATE ;
v2:
cvs版本
修改$(BOOST_ROOT)/tools/build/v2/tools/msvc.jam

#  8.0  adds some more options
 
一行的下方加上

flags msvc.compile CFLAGS $(condition) :  / wd4819  / D_CRT_SECURE_NO_DEPRECATE ;
 
boost 1.33.1版本

#  8.0  deprecates some of the options
     if   !  [ MATCH  ^ ([ 67 ]. * ) : $(version) ]
    {
        flags msvc.compile CFLAGS $(condition) /< optimization > speed :  / O2 ;
        flags msvc.compile CFLAGS $(condition) /< optimization > space :  / O1 ;
        flags msvc.link.dll MANIFEST :  " mt -manifest  "  ;
        flags msvc.link.dll OUTPUTRESOURCE :  " -outputresource: "  ;
    }
改为:

#  8.0  deprecates some of the options
     if   !  [ MATCH  ^ ([ 67 ]. * ) : $(version) ]
    {
        flags msvc.compile CFLAGS $(condition) :  / wd4819  / D_CRT_SECURE_NO_DEPRECATE ;
        flags msvc.compile CFLAGS $(condition) /< optimization > speed :  / O2 ;
        flags msvc.compile CFLAGS $(condition) /< optimization > space :  / O1 ;
        flags msvc.link.dll MANIFEST :  " mt -manifest  "  ;
        flags msvc.link.dll OUTPUTRESOURCE :  " -outputresource: "  ;

如何使用VS2005编译 转相关推荐

  1. VS2005编译QT4.8.2

    为什么要编译? 因为安装安装版的QT4.8.2,vs2005编译报错. 1.下载QT4.8.2,qt-everywhere-opensource-src-4.8.2.zip,下载vs-AddIn1.1 ...

  2. 使用 VS2005 编译 directshow sample 时链接错误

    Win7 系统下, 使用 VS2005 编译 Microsoft SDKs\Windows\v7.1\Samples\multimedia\directshow\filters\async 工程时, ...

  3. VS2005 编译环境,解决 Runtime Error(运行时错误): R6034。

    Posted on December 8, 2007 by 王永杰 问题:Runtime Error R6034 在VS2005编译环境下,用makefile编译的程序爆出了一个可恶的Runtime ...

  4. vs2005编译DNW050A

    *******************************LoongEmbedded******************************** 作者:LoongEmbedded 时间:201 ...

  5. GDI+在VS2005 编译不过的解决方法

    转自http://www.cnblogs.com/likebeta/archive/2012/04/16/2452160.html 1>------ 已启动生成: 项目: Photo, 配置: ...

  6. VS2005编译的时候提示“无法启动调试。绑定句柄无效”的错误怎么办?

    我同事的机器时 winxp sp2 + vs2005 每次调试vb.net 的 winForm 程序都是是 这个错误:  无法启动调试.绑定句柄无效 经过艰苦的折腾,终于找到原因了.原来需要改动编译设 ...

  7. VS2005编译的程序在XP系统下不能运行的解决办法

    我们有这样的经验,在VC6.0.VS2003下使用Use MFC in a shared DLL选项编译出来的程序,如果在一台纯洁的机器上运行,会弹出警告,提示我们缺少某些dll.我们乖乖的把那些库收 ...

  8. VS2005编译OpenGL红宝书示例代码

    原有的Makefilefor windows platform有点问题,需要修改. 首先从OpenGL官方网站下载示例代码的压缩包: http://www.opengl.org/resources/c ...

  9. VS2005混合编译ARM汇编代码

    2019独角兽企业重金招聘Python工程师标准>>> 在开发过程中,发现简单的在Storage Memory区域拷贝或粘贴文件不能达到硬件量测的要求,需要直接通过编写ARM汇编指令 ...

最新文章

  1. ORA-32004错误的解决方法
  2. git锁和钩子以及图形化界面
  3. Linux 用户空间和内核空间指的是什么?
  4. 如何将文件地址转为url_Node.js 源码解析 util.promisify 如何将 Callback 转为 Promise
  5. nagios 监控 mysql 读写比 R/W
  6. python 数字证书模拟登录_用于生成WebService使用的数字证书及签署证书.python脚本...
  7. Java中的HashSet
  8. 第一章 计算机网络 4 性能指标 [计算机网络笔记]
  9. 心电图 python_ST段凹面型向上抬高,一定是早期复极?心电图读图第201期
  10. 华为荣耀电脑第三方linux,【第三方Linux版】荣耀MagicBook Pro 16.1英寸全面屏如何?某东入手评测...
  11. (23)HTTP 状态消息
  12. 【报告分享】2020年数字政府新基建发展白皮书.pdf(附下载链接)
  13. 最短路径顶点算法:最短路径之迪杰斯特拉(Dijkstra)算法Strut2教程-java教程
  14. 2000,XP中显示器和系统匹配的问题?
  15. 使用ildasm反编译修改c# dll
  16. k8s报错error: You must be logged in to the server (Unauthorized)
  17. STM32F103C8T6定时器产生PWM
  18. 2023年3月份隐私计算市场洞察
  19. 关于自己搭建的邮件被微软反垃圾邮件标记为垃圾邮件
  20. python报错“ImportError: The _imagingft C module is not installed”

热门文章

  1. oracle ogg巡检,oracle 巡检内容
  2. Juniper SRX JSRP 配置文档
  3. 2020 年图灵奖得主 Ullman :做开源电子书,让肯掏钱买书的老实人免费读
  4. 如何理解配置?什么是配置?
  5. 谁说做大客户模式太重?容联云通讯成为SaaS领域另类领先者
  6. php 获取网络视频截图,100521 php取视频截图
  7. HTML5 简介及基础教程
  8. github下载的.ipynb文件报错unreadable Notebook NotJSONError
  9. 从小破站到大B站:哔哩哔哩变味了?
  10. 关于随身WiFi先回答一下的问题