再谈VS2010编译更高平台vs2012(v110),vs2015(v140)的objectARX程序

         前段时间我贴了一篇vs2010批量编译vc6~vs2008的ARX版本,实际上那一篇是我在研究vs2010编译v110,v140平台的附带收获,正应了那句话,有心栽花花不开,无心插柳柳成荫,因为vs2010编译更高版本的ARX目前需要的平台集是v110(vs2012,2013)和v140(vs2015,2017),分别对应CAD的R20(cad2015,2016),R21(cad2017,2018),而WindowsXp仅仅支持vs2010,所以必须使用win7以及以上的系统才能实现批量编译。

准备vs2012,vs2015绿色便携版,或者安装版。

绿色便携版下载地址,vs绿色便携版下载

下面我们来提取编译器,实际上vs开发工具集成编译环境IDE包含编辑器和编译器,而我们仅仅需要vc编译器+必要的windows SDK即可实现编译,

1,打开便携版目录,我们主要关心这两个文件夹。

先打开common7\IDE

找到以下4个文件,右键复制

 

 

 

进去VC\bin目录,粘贴,如果提示重复,可以跳过不覆盖。

在这个文件夹下面运行以下cl.exe,link.exe等exe,看是否能运行,可以打开cmd运行拖动exe到cmd中执行。。。。

已经能够提示用法,表示这个exe程序可以正常执行,其他的一样的可以测试一下。

下面我们为vs2010添加新的平台集,v140

打开如下路径

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\PlatformToolsets

新建两个文件夹,v140,v110

进入v90,选择这两个文件复制到v140,v110

粘贴到v140后,修改这两个文件的名字v90改v140

然后用记事本或者notepad++打开这两个文件。

替换所有v90文本为v140

找到这个文件的第一个<VCInstallDir>

 

 将目录改成你的vs2015的vc目录,如:E:\Visual Studio 2015 Enterprise\VC\ ,注意最后的斜杠。

我这个文件后面还有一个 <VCInstallDir Condition="'$(VCInstallDir)' == ''">d:\vc\vc9\</VCInstallDir> 这句可以不要,可以删除。。

按照上次的例子添加相关项目,如图。

现在我们可以用vs2010新建一个项目测试测试,看看有什么问题。。

更改项目平台为v140

 

 

直接编译。

 

 用everything搜索一下。

这个是我win10系统下的目录,因为我这台电脑上没有安装vs2015相关的windwos SDK,所以无法找到这个文件。。

所以必须找到一份windws10的SDK,因为我已经有了,我就不去折腾了,自行百度解决吧。而且这个文件夹有1.78G,不好上传。

回归主题,继续编辑Microsoft.Cpp.X64.v140 这个文件,找到第一个<WindowsSdkDir 后面的路径改为winsows10 SDK的路径如。

G:\Program Files (x86)\Windows Kits\10

 

 

再次编译。

这个是winver版本设置低了的缘故。打开项目文件的stdafx.h

 

替换一下

#if _MSC_VER < 1300
#define WINVER 0x0400
#elif _MSC_VER > 1500 // vc9
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
 
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
 
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0501 // Change this to the appropriate value to target Windows Me or later.
#endif
 
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0601 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#else
//- Modify the following defines if you have to target a platform prior to the ones specified below.
//- Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER          //- Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400      //- Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT      //- Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400    //- Change this to the appropriate value to target Windows 2000 or later.
#endif            

#ifndef _WIN32_WINDOWS      //- Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410  //- Change this to the appropriate value to target Windows Me or later.
#endif

#ifndef _WIN32_IE        //- Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400    //- Change this to the appropriate value to target IE 5.0 or later.
#endif
#endif

  

 再次编译

 

 

 启动调试

 

测试一下断点。

 

正常。。

至此,v140x64编辑完成,同样的方式,win32,v110都是类似的。。不再重复。。

附 上完整的x64 prop文件,仅供参考。

<!--
***********************************************************************************************
Microsoft.Cpp.x64.v140.props

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your projects from the command-line or the IDE.

Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(VCTargetsPath)\Platforms\x64\PlatformToolsets\v140\ImportBefore\*.props" Condition="Exists('$(VCTargetsPath)\Platforms\x64\PlatformToolsets\v140\ImportBefore')" />

  <PropertyGroup>
    <PlatformToolsetVersion>90</PlatformToolsetVersion>

    <VSInstallDir>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Setup\VS@ProductDir)</VSInstallDir>
    <VSInstallDir Condition="'$(VSInstallDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Setup\VS@ProductDir)</VSInstallDir>
    <VSInstallDir Condition="'$(VSInstallDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VCExpress\10.0\Setup\VS@ProductDir)</VSInstallDir>
    <VSInstallDir Condition="'$(VSInstallDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\10.0\Setup\VS@ProductDir)</VSInstallDir>
	
	<VCInstallDir>E:\Visual Studio 2015 Enterprise\VC\</VCInstallDir>
	<MyARXDir>C:\ObjectARX 2017\</MyARXDir>
	<MyPlatform>x64</MyPlatform>   
   

    <WindowsSdkDir Condition="'$(WindowsSdkDir)' == ''">G:\Program Files (x86)\Windows Kits\10\</WindowsSdkDir>
    

    <FrameworkDir Condition="'$(UseEnv)' != 'true'">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework@InstallRoot)</FrameworkDir>
    <FrameworkDir Condition="'$(FrameworkDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework@InstallRoot)</FrameworkDir>

    <FrameworkSdkDir Condition="'$(UseEnv)' != 'true'">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A@InstallationFolder)</FrameworkSdkDir>
    <FrameworkSdkDir Condition="'$(FrameworkSdkDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows@CurrentInstallFolder)</FrameworkSdkDir>
    <FrameworkSdkDir Condition="'$(FrameworkSdkDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v6.0A@InstallationFolder)</FrameworkSdkDir>
    <FrameworkSdkDir Condition="'$(FrameworkSdkDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows@CurrentInstallFolder)</FrameworkSdkDir>

    <FrameworkVersion Condition="'$(UseEnv)' != 'true'">v2.0.50727</FrameworkVersion>
    <Framework35Version Condition="'$(UseEnv)' != 'true'">v3.5</Framework35Version>

    <ExecutablePath Condition="'$(ExecutablePath)' == ''">$(VCInstallDir)bin\x86_amd64;$(VCInstallDir)bin;$(WindowsSdkDir)bin;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(FrameworkSDKDir)bin;$(FrameworkSDKDir)lib\win64;$(FrameworkDir)$(FrameworkVersion);$(FxCopDir);$(PATH);</ExecutablePath>
    <IncludePath Condition="'$(IncludePath)' == ''">$(WindowsSdkDir)Include\10.0.15063.0\um;$$(WindowsSdkDir)Include\10.0.15063.0\winrt;$(WindowsSdkDir)Include\10.0.15063.0\ucrt;$(WindowsSdkDir)Include\10.0.15063.0\shared;$(MyARXDir)inc;$(MyARXDir)inc-x64;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)include;</IncludePath>
    <ReferencePath Condition="'$(ReferencePath)' == ''">$(VCInstallDir)atlmfc\lib\amd64;$(VCInstallDir)lib\amd64</ReferencePath>
    <LibraryPath Condition="'$(LibraryPath)' == ''">$(WindowsSdkDir)Lib\10.0.15063.0\um\x64;$(WindowsSdkDir)Lib\10.0.15063.0\ucrt\x64;$(MyARXDir)lib-x64;$(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(WindowsSdkDir)lib\x64;</LibraryPath>
    <SourcePath Condition="'$(SourcePath)' == ''">$(VCInstallDir)atlmfc\src\mfc;$(VCInstallDir)atlmfc\src\mfcm;$(VCInstallDir)atlmfc\src\atl;$(VCInstallDir)crt\src;</SourcePath>
    <ExcludePath Condition="'$(ExcludePath)' == ''">$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)include;$(FrameworkDir)$(FrameworkVersion);$(VCInstallDir)atlmfc\lib\amd64;$(VCInstallDir)lib\amd64;</ExcludePath>
    <NativeExecutablePath Condition="'$(NativeExecutablePath)' == ''">$(VCInstallDir)bin\AMD64;$(VCInstallDir)VCPackages;$(WindowsSdkDir)bin\x64;$(WindowsSdkDir)bin\win64\x64;$(WindowsSdkDir)bin;$(FrameworkDir)\$(FrameworkVersion);$(FrameworkDir)\$(Framework35Version);$(PATH);</NativeExecutablePath>
  </PropertyGroup>

  <Import Project="$(VCTargetsPath)\Platforms\x64\PlatformToolsets\v140\ImportAfter\*.props" Condition="Exists('$(VCTargetsPath)\Platforms\x64\PlatformToolsets\v140\ImportAfter')" />
</Project>

  

 

转载于:https://www.cnblogs.com/edata/p/8061127.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\ 是用于配置和自定义编译过程的目录。根据引用的描述,这个目录的文件可以用于配置OpenCV并解决一些与项目配置相关的问题。具体来说,这个目录的文件可以在VS2019找不到Microsoft.Cpp.X64.user文件时使用。根据引用的描述,可以通过在解决方案资源管理器右键单击项目,然后选择属性,进入链接器->常规选项,并将逐用户重定向设置为TRUE来配置相关属性。这样做可以确保项目在编译时使用正确的配置和自定义选项。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [npm-msbuild:从Node.js运行msbuild.exe](https://download.csdn.net/download/weixin_42102634/15209435)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [VS2019配置OpenCV时找不到Microsoft.Cpp.x64.user的解决方法](https://download.csdn.net/download/weixin_38668672/13740546)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(1621,5): error MS](https://blog.csdn.net/qq_22521211/article/details/78730449)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值