win8+vs和linux下安装和简单使用ace.docx
- 文档编号:16269522
- 上传时间:2023-07-12
- 格式:DOCX
- 页数:16
- 大小:358.08KB
win8+vs和linux下安装和简单使用ace.docx
《win8+vs和linux下安装和简单使用ace.docx》由会员分享,可在线阅读,更多相关《win8+vs和linux下安装和简单使用ace.docx(16页珍藏版)》请在冰点文库上搜索。
win8+vs和linux下安装和简单使用ace
目录
1.概要2
2.获取ace2
3.Win8+VisualStudio20122
3.1.编译2
3.1.1.解压:
2
3.1.2.定义config.h3
3.1.3.加载对应的VC工程文件3
3.2.使用ace库5
3.2.1.PropertyManage(属性管理器)配置5
3.2.2.头文件和库文件目录配置7
3.2.3.使用VisualStudio编程10
3.3.碰到问题11
4.Linuxas5u2环境下使用ace11
4.1.编译ace11
4.2.例程15
4.3.注意点16
1.概要
本文描述在VisualStudio2012环境下安装ace。
主要内容有:
1、获取Ace安装包;
2、在win8+VisualStudio2012环境下安装ace
3、在Linuxas5u2环境下安装ace。
2.获取ace
url:
http:
//www.cs.wustl.edu/~schmidt/ACE.html
安装包为:
ACE-5.8.0.tar.gz。
安装步骤参照ACE_ROOT/ACE-INSTALL.html
3.Win8+VisualStudio2012
3.1.编译
3.1.1.解压:
UncompresstheACEdistributionintoadirectory,whereitwillcreateaACE_wrappersdirectorycontainingthedistribution.TheACE_wrappersdirectorywillbereferredtoasACE_ROOTinthefollowingsteps--soACE_ROOT\acewouldbeC:
\ACE_wrappers\aceifyouuncompressedintotherootdirectory.
备注:
将下载的压缩包ACE-5.8.0.tar.gz解压到N:
/public/ACE-5.8.0/,因此本文中定义
ACE_ROOT为N:
/public/ACE-5.8.0/ACE_wrappers
3.1.2.定义config.h
Createafilecalled config.h intheACE_ROOT\acedirectorythatcontains:
备注:
在目录ACE_ROOT/ace下新建文件config.h,文件中内容为:
#include"ace/config-win32.h"
3.1.3.加载对应的VC工程文件
3.Thestatic,DLLandMFClibrarybuildsarekeptindifferentworkspaces.Fileswithnames*_Staticcontainprojectfilesforstaticbuilds.WorkspacesforstaticandDLLbuildswillbeavailablethroughthestockreleaseatDOCgroup'swebsite.TheworkspacesforMFCarenotavailableandhavetobegeneratedusingMPC.Pleasesee MPC'sREADME fordetails.
4.NowloadthesolutionfileforACE(ACE_ROOT/ACE.sln).
5.TouseACEwithMFClibraries,alsoaddthefollowingtoyour config.h file.NoticethatifyouwanttospawnanewthreadwithCWinThread,makesureyouspawnthethreadwithTHR_USE_AFXflagset.
#defineACE_HAS_MFC1
Bydefault,alloftheACEprojectsusetheDLLversionsoftheMSVCrun-timelibraries.Youcanstillchooseusethestatic(LIB)versionsofACElibrariesregardlessofrun-timelibraries.Thereasonwechosetolinkonlythedynamicrun-timelibraryisthatalmosteveryNTboxhastheselibraryinstalledandtosavediskspace.IfyouprefertolinkMFCasastaticlibraryintoACE,youcandothisbydefining ACE_USES_STATIC_MFC inyourconfig.h file.However,ifyouwouldliketolinkeverything(includingtheMSVCrun-timelibraries)statically,you'llneedtomodifytheprojectfilesinACEyourself.
6.StaticversionofACElibrariesarebuiltwith ACE_AS_STATIC_LIBS
defined.ThismacroshouldalsobeusedinapplicationprojectsthatlinktostaticACElibraries
Optionallyyoucanalsoaddtheline
#defineACE_NO_INLINE
beforethe#includestatementinACE_ROOT\ace\config.htodisableinlinefunctionandreducethesizeofstaticlibraries(andyourexecutables.)
7.ACEDLLandLIBnamingscheme:
WeusethefollowingrulestonametheDLLandLIBfilesinACEwhenusingMSVC.
"Library/DLLname"+(Isstaticlibrary?
"s":
"")+(IsDebuggingenable?
"d":
"")+{".dll"|".lib"}
备注:
这一段比较复杂,讲到了采用DLL和LIB等方式需要注意的地方。
在后续章节讲使用ace编译程序,本人会进行详细补充说明。
此处,本人比较喜欢使用静态库文件,因此加载了ACE_ROOT\lib的ace_vc9_Static.sln。
加载后,VisualStudio会自动升级工程文件。
加载后请编译。
经过几十分钟的等待,在ACE_ROOT\lib会生成静态库文件,其中我们经常用的是ACEsd.lib。
此处有几个小问题。
1)如果直接加载ACE_ROOT下的ACE_vc9.sln,由于此工程文件加载内容较多,在编译过程中,可能发生VisualStudio崩溃的现象。
建议加载ACE_ROOT\ace目录下的ACE_vc9.sln。
2)如果打开ACE_vc9.sln,此时在使用ace库时,需要加生成的ACE_ROOT\lib下的dll动态库文件拷到当前生成项目的输入库目录下。
为了解决这个问题,可以加载ace_vc9_Static.sln。
但是很遗憾,从ace6开始,这个静态的工程文件不在安装包中,我在网上也找了半天,还是没有发现。
3.2.使用ace库
ConfigurationType:
Staticlib和App
VC++Directory:
include和library需要添加ace、cppunit、boost的相关目录
PreprocessorDifinition:
增加ACE_AS_STATIC_LIBS
RuntimeLibrary:
MTd
在VisualStudio使用ace时,首先要设置好头文件和lib库的相关配置。
这是全局配置,这样才能在以后新建的工程中,默认可以使用ace库。
本节主要叫各位逐步配置。
3.2.1.PropertyManage(属性管理器)配置
编译好ace后,就需要在将ace的头文件和库文件目录配置到VisualStudio的通用属性中。
首先要讲的是以前版本的visualstudio,都是从Tools-》options->ProjectSolution->VC++directions但是从VisualStudo2010开始就无法使用了。
郁闷吧。
淡定一下,Follow飞天!
第一步:
选择View(视图)找到Propertymanage(属性管理器),或者点击扳手图标,可以直接打开Propertymanage。
网上的资料都这么说,但是你会发现内容为空,第二次郁闷吧。
其实很简单,随便打开或者新建一个项目,然后就可以打开了,呵呵。
也就是说,必须新建或者打开一个项目后,才能看到PropertyManage窗口。
第二步:
选择View(视图)找到Propertymanage(属性管理器),注意不是属性窗口(propertyWindow)也不是propertypage(属性页)。
是不是找不到(呵呵,第三次郁闷吧)。
很简单,PropertyManage可能在otherwindow(其他窗口)的下一级菜单中找到!
第三步:
属性管理器中,找到通用而不是单个项目的VC++Directory设置。
按照网上的教程,发现这个图中的CommonProperties空空如也,没有你要的东西(第三次郁闷,呵呵)。
注意了:
想得到下面图中的效果吧_^_^!
淡定,justfollow飞天。
按照红色标志,依此点击小三角,最后选择双击“Microsoft.Cpp.Win32.user”,就可以设置所有项目共用的配置效果了。
3.2.2.头文件和库文件目录配置
在正确打开PropertyManage(属性管理器)的通用属性配置窗口后,需要配置ace的头文件和库文件,需要配置的内容如下:
本文中采用静态库编译方式,所以需要在预处理器定义中增加ACE_AS_STATIC_LIBS。
ACE_BUILD_DLL;
$(OutDir)ACEd.dll
运行库改成多线程调试模式:
在连接器中增加ace静态库的链接库文件
第四步:
编译一个项目,发现propertymanage的修改没有生效(第四次郁闷)。
注意了,点击修改保存,再点击“应用”,或者重启visualstudio。
怎么样,生效了吧。
呵呵
3.2.3.使用VisualStudio编程
1)Main函数的定义有要求,必须定义
intmain(intargc,char**argv)
不能用main()
2)Debug或者Release必须保持一致。
3)调试中的命令参数,用来定义输入的参数
4)为了尽快入门,建议按照ADDISON–WESLEY的TheACEProgrammer’sGuide深入学习。
3.3.碰到问题
从ace6.1开始,下载包中没有了编译静态库的工程文件,很奇怪。
要不然我这篇文档就改用ace6.1了。
4.Linuxas5u2环境下使用ace
在linux下本人使用了ACE-6.1.0.tar.gz安装包。
编译过程相对于以前版本,过程变得复杂了。
4.1.编译ace
1.准备安装包
将安装包上载到/root下。
执行命令:
tarxvfzACE-6.1.0.tar.gz
将ace6解压开会生成目录ACE_wrappers/
2.配置目录
AddanenvironmentvariablecalledACE_ROOTthatcontainsthenameoftherootofthedirectorywhereyoukeeptheACEwrappersourcetree.TheACErecursiveMakefileschemeneedsthisinformation.ThereareseveralwaystosettheACE_ROOTvariable.Forexample:
TSCH/CSH:
setenvACE_ROOT/root/ACE_wrappers
BASHorBourneShell:
ACE_ROOT=/root/ACE_wrappers;exportACE_ROOT
Ifyou'rebuildinganumberofversionsofACE,however,(e.g.,fordifferentOSplatformsorfordifferentreleasesofACE)youmightusethefollowingapproach(assumingTCSH/CSH):
setenvACE_ROOT$cwd
备注:
配置ACE_ROOT目录,在.bash_profile文件末尾增加一行:
exportACE_ROOT=/root/ACE_wrappers
3.准备config.h
Createaconfigurationfile, $ACE_ROOT/ace/config.h,thatincludestheappropriateplatform/compiler-specificheaderconfigurationsfromtheACEsourcedirectory.Forexample:
#include"ace/config-linux.h"
Theplatform/compiler-specificconfigurationfilecontainsthe#definesthatareusedthroughoutACEtoindicatewhichfeaturesyoursystemsupports.Seethe $ACE_ROOT/ace/README fileforadescriptionofthesemacrosettings.Ifyoudesiretoaddsomesite-specificorbuild-specificchanges,youcanaddthemtoyourconfig.hfile;placethem before theinclusionoftheplatform-specificheaderfile.
ThereareconfigfilesformostversionsofUNIX.Ifthereisn'taversionofthisfilethatmatchesyourplatform/compiler,you'llneedtomakeone.Pleasesendemailtothe ace-users listifyougetitworkingsoitcanbeaddedtothemasterACErelease.
备注:
创建新文件$ACE_ROOT/ace/config.h,并增加一行:
#include"ace/config-linux.h"
头文件中,可以根据需要,增加一些配置,详见$ACE_ROOT/ace/README。
4.准备配置文件platform_macros.GNU
Createabuildconfigurationfile, $ACE_ROOT/include/makeinclude/platform_macros.GNU,thatcontainstheappropriateplatform/compiler-specificMakefileconfigurations,e.g.,
include$(ACE_ROOT)/include/makeinclude/platform_linux.GNU
ThisfilecontainsthecompilerandMakefiledirectivesthatareplatform/compiler-specific.Ifyou'dliketoaddmakeoptions,youcanaddthembeforeincludingtheplatform-specificconfiguration.
NOTE!
Therereallyisnota#characterbefore'include'intheplatform_macros.GNUfile.#isacommentcharacter.
备注:
创建文件$ACE_ROOT/include/makeinclude/platform_macros,并在该文件中增加一行:
include$(ACE_ROOT)/include/makeinclude/platform_linux.GNU
5.准备配置文件platform_macros.GNU
IfyouwishtoinstallACE(using"makeinstall"),settheinstallationprefixinplatform_macros.GNU.
INSTALL_PREFIX=/usr/local
Headerswillbeinstalledto$INSTALL_PREFIX/include,executablesto$INSTALL_PREFIX/bin,documentationandbuildsystemfilesto$INSTALL_PREFIX/shareandlibrariesto$INSTALL_PREFIX/lib.ThelibrarydirectorycanbecustomizedbysettingINSTALL_LIB(forexample,INSTALL_LIB=lib64).WithINSTALL_PREFIXset,RPATHwillbeenabledforallexecutablesandsharedlibraries.TodisableRPATH(forexample,if$INSTALL_PREFIX/$INSTALL_LIBisalreadyasystem-knownlocationforsharedlibrariessuchasthoselistedin/etc/ld.so.conf),setthemakemacroinstall_rpathto0byaddinginstall_rpath=0toplatform_macros.GNU.
备注:
在配置文件$ACE_ROOT/include/makeinclude/platform_macros,并在该文件中增加一行:
INSTALL_PREFIX=/usr/local
这个配置文件在编译过程中要用到。
可执行文件放到该目录下的bin目录下;文档和编译文件放到该目录下的share目录下;库文件在该目录的/lib目录下。
6.配置LD_LIBRARY_PATH
NotethatbecauseACEbuildssharedlibraries,you'llneedtosetLD_LIBRARY_PATH(orequivalentforyourplatform)tothedirectorywherebinaryversionoftheACElibraryisbuiltinto.Forexample,youprobablywanttodosomethinglikethefollowing:
%setenvLD_LIBRARY_PATH$ACE_ROOT/lib:
$LD_LIBRARY_PATH
备注:
在/root/.bash_profile中增加:
LD_LIBRARY_PATH=$ACE_ROOT/lib:
$LD_LIBRARY_PATH
exportLD_LIBRARY_PATH
7.编译ace
Whenallthisisdone,hopefullyallyou'llneedtodoistype:
%make
attheACE_ROOTdirectory.ThiswillbuildtheACElibrary,tests,theexamples,andthesampleapplications.BuildingtheentireACEreleasecantakealongtimeandconsumelotsofdiskspace,however.Therefore,youmightconsidercd'ingintothe $ACE_ROOT/ace directoryandrunning make theretobuildjusttheACElibrary.Asasanitycheck,youmightalsowanttobuildandruntheautomated "one-button"tests in $ACE_ROOT/tests.Finally,ifyou'realsoplanningonbuilding TAO,youshouldbuildthe gperf perfecthashfunctiongeneratorapplicationin $ACE_ROOT/apps/gperf.
备注:
编译ace。
可以直接在目录ACE_ROOT下直接执行make命令编译所有库文件。
为了节约时间,可以在目录ACE_ROOT/ace下执行make命令。
另外为了验证ace是否正确编译,可以编译并执行“one-botton”测试程序。
8.安装ace
Ifyou'vesettheINSTALL_PREFIXbeforebuilding,nowrun
%makein
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- win8 vs linux 安装 简单 使用 ace