再談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>

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM