Supporting x64 and Win32 within one solution
From WxWiki
Contents |
[edit] Preface
The typical programmer will face a build problem, if he's going to compile his application for Win32 and for x64 platforms. The .sln 's and .vcproj 's which are generated from .dsw 's and .dsp 's support only Win32. However, you can add x64 support to the project files. If you have read the description in INSTALL-MSW.txt you know that you only need to go to the 'Build' menu and choose 'Configuration Manager...' and add 'x64'. But if you now build Win32 libraries and x64 libraries you'll end up having several linker errors and a mixed set of libraries (some for Win32 and some for x64).
This problem can be solved if you edit build/msw/*.vcproj (all of them) and the file include/msvc/wx/setup.h.
[edit] Editing *.vcproj in the directory build/msw:
[edit] Changing them with gawk.exe
If you have gawk.exe, you can use it to make the needed changes. Go into the directory build/msw and create following two files. Than execute VC2005_MultiTargetSupport.bat.
VC2005_MultiTargetSupport.awk
{
PlatformPath = "\\$(PlatformName)"
split ("vc_lib vc_dll vc_mswu vc_mswuniv vc_mswunivu vc_mswunivddll vc_mswdll vc_mswunivdll vc_msw vc_mswudll vc_mswunivudll vc_mswunivud vc_mswunivd vc_mswuddll vc_mswud vc_mswddll vc_mswd vc_mswunivuddll", wxNames)
for (name in wxNames)
{
while (0!=match($0, "^(.*)([^[:alnum:]_])"wxNames[name]"([^[:alnum:]_])(.*)$", text ) )
{
$0 = text[1] text[2] wxNames[name] "DONTFINDMEAGAIN" PlatformPath text[3] text[4]
}
gsub("DONTFINDMEAGAIN", "")
}
print $0
}
VC2005_MultiTargetSupport.bat
@echo off for %%I in (*.vcproj) do ren %%I %%I.old && gawk -f VC2005_MultiTargetSupport.awk %%I.old > %%I rem for %%I in (*.vcproj) do gawk -f wxExtender.awk %%I > %%I.new
[edit] Changing them manually
If you don't have gawk.exe, prepare for half an hour of work!
Please add the string
\$(PlatformName)
after each occurence of following strings:
vc_lib vc_dll vc_mswu vc_mswuniv vc_mswunivu vc_mswunivddll vc_mswdll vc_mswunivdll vc_msw vc_mswudll vc_mswunivudll vc_mswunivud vc_mswunivd vc_mswuddll vc_mswud vc_mswddll vc_mswd vc_mswunivuddll
You should end up having changed the lines which begin with one of these xml names (.vcproj files are xml files):
OutputDirectory IntermediateDirectory TypeLibraryName AdditionalIncludeDirectories PrecompiledHeaderFile AssemblerListingLocation ObjectFile ProgramDataBaseFileName AdditionalIncludeDirectories AdditionalDependencies OutputFile AdditionalLibraryDirectories ProgramDatabaseFile ImportLibrary OutputFile
Here is an example of how such a change would look alike:
<Configuration Name="DLL Unicode Debug|Win32" OutputDirectory=".\..\..\lib\vc_dll\$(PlatformName)" IntermediateDirectory=".\vc_mswuddll\$(PlatformName)\adv" ConfigurationType="2" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="1" > ... <Tool Name="VCMIDLTool" PreprocessorDefinitions="WIN32,_USRDLL,DLL_EXPORTS,_DEBUG,__WXMSW__,__WXDEBUG__,_UNICODE,WXUSINGDLL,WXMAKINGDLL_ADV" MkTypLibCompatible="true" SuppressStartupBanner="true" TargetEnvironment="1" TypeLibraryName=".\..\..\lib\vc_dll\$(PlatformName)/wx_adv.tlb" HeaderFileName="" /> <Tool Name="VCCLCompilerTool" AdditionalOptions="/EHsc " Optimization="0" AdditionalIncludeDirectories="..\..\lib\vc_dll\$(PlatformName)\mswud,..\..\include,..\..\src\tiff,..\..\src\jpeg,..\..\src\png,..\..\src\zlib,..\..\src\regex,..\..\src\expat\lib" PreprocessorDefinitions="WIN32;_USRDLL;DLL_EXPORTS;_DEBUG;__WXMSW__;__WXDEBUG__;WXUSINGDLL;WXMAKINGDLL_ADV" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" RuntimeTypeInfo="true" UsePrecompiledHeader="2" PrecompiledHeaderThrough="wx/wxprec.h" PrecompiledHeaderFile="vc_mswuddll\$(PlatformName)\wxprec_advdll.pch" AssemblerListingLocation=".\vc_mswuddll\$(PlatformName)\adv/" ObjectFile=".\vc_mswuddll\$(PlatformName)\adv/" ProgramDataBaseFileName="..\..\lib\vc_dll\$(PlatformName)\wxmsw270ud_adv_vc_custom.pdb" WarningLevel="4" SuppressStartupBanner="true" DebugInformationFormat="3" /> <Tool Name="VCManagedResourceCompilerTool" /> <Tool Name="VCResourceCompilerTool" PreprocessorDefinitions="_DEBUG,__WXMSW__,__WXDEBUG__,_UNICODE,WXDLLNAME=wxmsw270ud_adv_vc_custom,WXUSINGDLL,WXMAKINGDLL_ADV" Culture="1033" AdditionalIncludeDirectories="..\..\lib\vc_dll\$(PlatformName)\mswud;..\..\include;..\..\src\tiff;..\..\src\jpeg;..\..\src\png;..\..\src\zlib;..\..\src\regex;..\..\src\expat\lib" /> <Tool Name="VCPreLinkEventTool" /> <Tool Name="VCLinkerTool" AdditionalDependencies="wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib winmm.lib comctl32.lib rpcrt4.lib wsock32.lib odbc32.lib ..\..\lib\vc_dll\$(PlatformName)\wxmsw27ud_html.lib ..\..\lib\vc_dll\$(PlatformName)\wxbase27ud_xml.lib ..\..\lib\vc_dll\$(PlatformName)\wxmsw27ud_core.lib ..\..\lib\vc_dll\$(PlatformName)\wxbase27ud.lib" OutputFile="..\..\lib\vc_dll\$(PlatformName)\wxmsw270ud_adv_vc_custom.dll" LinkIncremental="2" SuppressStartupBanner="true" AdditionalLibraryDirectories="..\..\lib\vc_dll\$(PlatformName)" GenerateDebugInformation="true" ProgramDatabaseFile=".\..\..\lib\vc_dll\$(PlatformName)/wxmsw270ud_adv_vc_custom.pdb" ImportLibrary="..\..\lib\vc_dll\$(PlatformName)\wxmsw27ud_adv.lib" TargetMachine="1" /> <Tool Name="VCALinkTool" /> ... <Tool Name="VCXDCMakeTool" /> <Tool Name="VCBscMakeTool" SuppressStartupBanner="true" OutputFile=".\..\..\lib\vc_dll\$(PlatformName)/wx_adv.bsc" /> <Tool Name="VCFxCopTool" /> <Tool Name="VCAppVerifierTool" ... <Tool Name="VCPostBuildEventTool" /> </Configuration>
Again: These changes have to be done to all *.vcproj! Yes, this is a lot of work. Maybe someone can write a script which works with tools which are included by default in Windows (like VBScript or similar).
[edit] Editing setup.h in the directory include/msvc/wx:
(There are several files named setup.h in the wxWidgets directory tree. Please be careful to modify the correct one.)
It's difficult to describe what you need to do now. In this case examples are better than words, so here it goes:
The unmodified setup.h might look like this
...
#ifdef WXUSINGDLL
#ifdef _DEBUG
#include "../../../lib/vc_dll/mswud/wx/setup.h"
#else
#include "../../../lib/vc_dll/mswu/wx/setup.h"
#endif
#else
#ifdef _DEBUG
#include "../../../lib/vc_lib/mswud/wx/setup.h"
#else
#include "../../../lib/vc_lib/mswu/wx/setup.h"
#endif
#endif
...
#else // !_UNICODE
#ifdef WXUSINGDLL
#ifdef _DEBUG
#include "../../../lib/vc_dll/mswd/wx/setup.h"
#else
#include "../../../lib/vc_dll/msw/wx/setup.h"
#endif
#else // static lib
#ifdef _DEBUG
#include "../../../lib/vc_lib/mswd/wx/setup.h"
#else
#include "../../../lib/vc_lib/msw/wx/setup.h"
#endif
#endif // shared/static
The modified setup.h must look like this
...
#ifdef WXUSINGDLL
#ifdef _DEBUG
#ifdef _WIN64
#include "../../../lib/vc_dll/x64/mswud/wx/setup.h"
#else
#include "../../../lib/vc_dll/Win32/mswud/wx/setup.h"
#endif
#else
#ifdef _WIN64
#include "../../../lib/vc_dll/x64/mswu/wx/setup.h"
#else
#include "../../../lib/vc_dll/Win32/mswu/wx/setup.h"
#endif
#endif
#else
#ifdef _DEBUG
#ifdef _WIN64
#include "../../../lib/vc_lib/x64/mswud/wx/setup.h"
#else
#include "../../../lib/vc_lib/Win32/mswud/wx/setup.h"
#endif
#else
#ifdef _WIN64
#include "../../../lib/vc_lib/x64/mswu/wx/setup.h"
#else
#include "../../../lib/vc_lib/Win32/mswu/wx/setup.h"
#endif
#endif
#endif
...
#else // !_UNICODE
#ifdef WXUSINGDLL
#ifdef _DEBUG
#ifdef _WIN64
#include "../../../lib/vc_dll/x64/mswd/wx/setup.h"
#else
#include "../../../lib/vc_dll/Win32/mswd/wx/setup.h"
#endif
#else
#ifdef _WIN64
#include "../../../lib/vc_dll/x64/msw/wx/setup.h"
#else
#include "../../../lib/vc_dll/Win32/msw/wx/setup.h"
#endif
#endif
#else // static lib
#ifdef _DEBUG
#ifdef _WIN64
#include "../../../lib/vc_lib/x64/mswd/wx/setup.h"
#else
#include "../../../lib/vc_lib/Win32/mswd/wx/setup.h"
#endif
#else
#ifdef _WIN64
#include "../../../lib/vc_lib/x64/msw/wx/setup.h"
#else
#include "../../../lib/vc_lib/Win32/msw/wx/setup.h"
#endif
#endif
#endif // shared/static
...
[edit] Final Notes
I have done this with the HEAD version of CVS and it works. Unfortunalty, I don't know if the samples will compile and link seamless with these changes. If they don't work, you will need to change the project file similar to above.
