IdeaMonk

thoughts, ideas, code and other things...

Sunday, March 22, 2009

The 64-32 bits issues in Visual Studio 2008 Express

I remember having a hard time fighting 64 and 32 bit issues while testing emgu.CV last month for Project SpaceLock. Final conclusion was to recompile OpenCV for 64-bits and then we had class tests and T2 @ college, due to which issue finally lost interest.
Well, it came up again today when Harsha sent a compiled example from emgu.CV for test on Vista 64 bit. Ooops, 'This program has stopped working...'. WTF, then I tried getting the sample working on my own VS2008 Express, but no success at all.
Google said many more developers are frustrated like you :) And finally an article on Bytes opened my eyes into a simple one-liner -
Well, the Express Edition of Visual Studio 2008 doesn't let you choose the target platform for your build. What I mean here is that if you're on a 64 bit machine with Vista-64, you won't be finding any drop-down in Project Properties to help you change the target.

Jon Skeet [C# MVP] has an interesting solution:
In your .csproj file, just make the changes shown in bold
<PlatformTargetelement >
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
>
That's all! for my version of VS2008 Express things look like this after the change-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>

Just below that, you've the configuration for Release version, add the PlatformTarget tag there too.

So, we would be maintaing all the modules of SpaceLock with x86 as target for now. Since the Emgu.CV & OpenCV binaries we have are in 32 bit, it would be wise and quicky to do this.

Labels: , ,

1 Comments:

At November 20, 2011 at 9:08 PM , Anonymous Anonymous said...

thanks, you save me:)

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home