Thursday, December 07, 2006

C++: Visual C++ 2005 Express Edition x64

Visual C++ 2005 Express Edition is a free 32 bit IDE and compiler offered by microsoft. It has limitations (no resource editor, no MFC) but you can build command line apps with it ok, and if you set it up properly you can build apps for x64. This is helpful particularly if you have an x64 system, and don't want to pay for Visual Studio 2005 which has support for x64 compilation. To enable x64 install the free Microsoft Platform SDK. Then depending on what you're programming you may want the .NET Framework SDK 2.0 (x64).

download links


After installing these, you need to configure Visual C++ Express to compile with the Platform SDK libraries.
go to Tools > Options > Projects and Solutions > VC++ Directories and set the following:
Executable files: C:\Program Files\MS_Platform_SDK\Bin
Include files: C:\Program Files\MS_Platform_SDK\Include
Library files: C:\Program Files\MS_Platform_SDK\Lib
Note: depending on where you installed the platform sdk you may have to use "Microsoft Platform SDK for Windows Server 2003 R2" as "MS_Platform_SDK" above.


Now, open up the x64 open build debug/retail environment window (came with Platform SDK). It will look like a command-line interface. From that command-line go to the folder where "VCExpress.exe" is located and call it. Now when you build apps it will build with the x64 libraries.

Then, you need to modify some default settings in your projects.

To compile for x64, create 'x64' in the configuration manager for x64 (copy settings from win32), then verify and set the following project settings:
* /MACHINE (Specify Target Platform) is set to /MACHINE:AMD64.
* Register Output is turned OFF.
* If Debug Information Format was set to /ZI in the Win32 project configuration, then it is set to /Zi in the 64-bit project configuration. For more information, see /Z7, /Zi, /ZI (Debug Information Format).
* Values of WIN32 are replaced by WIN64 for /D (Preprocessor Definitions).


When linking, if you get errors like:
"error LNK2001: unresolved external symbol _RTC_Shutdown"
then set "Basic Runtime Checks" to Default in the project settings.

When linking, if you get errors like:
fatal error LNK1112: module machine type 'AMD64' conflicts with target machine type 'x64', you need to make sure you use /MACHINE:AMD64 and not /MACHINE:x64. If it won't let you, change to "Not Set", then add it explicitly under Additional Linker Options.

When running your app you may get an error saying msvcrtd.dll not found. Go to your platform SDK folder, and go to noredist/win64/amd64 and you will find it there, copy it into your system32 folder. Don't use the one in noredist/win64/ like i did at first, it doesn't help.

sources:
http://msdn2.microsoft.com/en-us/library/9yb4317s(VS.80).aspx
http://www.planetamd64.com/lofiversion/index.php/t18796.html
http://www.planetamd64.com/lofiversion/index.php/t5934.html

CSS: Block IE 'active content' bar

I don't know what implications this has, the IE 'warning active content' bar pops up on safe CSS using ActiveX, but the message may be coming up legitimately.

Problem: I wanted to have a fancy gradient in the background of a button for IE users only. I found css code supposedly uses activeX to achieve this.
CSS code:
.btn { filter:progid:DXImageTransform.Microsoft.Gradient(
GradientType=0,StartColorStr='#ffD3D7E0',EndColorStr='#ff8C939B');}


But when I view the HTML page on my local computer I see:
"To help protect you security, Internet Explorer has restricted this file from showing active content that could access your computer"

Solution: I found a forum that said when you deploy it to HTTP this message goes away. Another alternative is to include the following code.

<!-- Start Information Bar Blocking Code -->
<!-- saved from url=(0027)http://www.blockingspoof.com/dumbie.html -->
<!-- End Information Bar Blocking Code -->


However I noticed that while the IE-Bar goes away, I don't think it addresses this issue: (an IE security flaw which I also found) which leads me to think the IE Bar is legitimately popping up (because of insecure code).
see: http://osvdb.org/27109