Help - Search - Members - Calendar
Full Version: Set up Visual C++ 2005 Express for x64 compiling
PlanetAMD64 > Software > Software Development
Fearan
Hi all,

I have been trying for some time to find an effective way to compile x64 apps in windows. I have been rocking back and forth between trying to build gcc 4 and trying to set up visual studio. I have tried vc2k3 .net, and vc2k5 express. It has not been a very nice experience. It seems the only clean way to do it is to buy Visual Studio 2005... but I don't feel like paying $400 for about 5 other languages I won't be using anyway. So I'm still trying to find a way to compile x64 apps in Visual C++ 2005 Express. I have the PSDK installed, and I know where cl and link are, etc, etc. I just need to know how to set up the paths and any other options so I can build x64 apps.

Here is my current status:
OS: Windows XP x64 Pro
VS: Visual C++ 2005 Express
PSDK: Installed

Thanks for any following help!
Fearan
kingdesmond
I'm pretty sure that you can not compile 64 bit exe's in the Express editions.

I have made a few 64 bit apps in the Professional edition of VS2005(but Standard would work too). You just go to the advanced compile options, then in the list box at the bottom choose the target CPU.

You might be able to use the special command prompt that is part of the SDK to compile a 64 bit app, but I'm not quite sure on how to do that.
brewin
http://msdn2.microsoft.com/en-us/library/9yb4317s.aspx

Read the note about the Express version.
Fearan
QUOTE(brewin @ Feb 20 2006, 03:50 PM)
http://msdn2.microsoft.com/en-us/library/9yb4317s.aspx

Read the note about the Express version.
*

So I would need to install .net Framework SDK 2.0? I'll try that... It seems to be the problem, according to the note.
Fearan
That really didn't do much... now i'm getting the following error:

------ Build started: Project: hellox64, Configuration: Debug Win32 ------
Compiling...
hellox64.cpp
Compiling manifest to resources...
Linking...
.\Debug\hellox64.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
Build log was saved at "file://c:\Documents and Settings\Fearan Iluviathalion\My Documents\Visual Studio 2005\Projects\hellox64\hellox64\Debug\BuildLog.htm"
hellox64 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
brewin
QUOTE(Fearan @ Feb 20 2006, 06:05 PM)
That really didn't do much... now i'm getting the following error:

------ Build started: Project: hellox64, Configuration: Debug Win32 ------
Compiling...
hellox64.cpp
Compiling manifest to resources...
Linking...
.\Debug\hellox64.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
Build log was saved at "file://c:\Documents and Settings\Fearan Iluviathalion\My Documents\Visual Studio 2005\Projects\hellox64\hellox64\Debug\BuildLog.htm"
hellox64 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
*

Try running VCExpress with the "/useenv" switch.
Fearan
QUOTE(brewin @ Feb 20 2006, 08:11 PM)
Try running VCExpress with the "/useenv" switch.
*

all that did was replace the build paths with my system environment paths... not very helpful... i'll have to explore it in more detail later.
Fearan
Jeez... i just did some thinking and had an epiphany... what if the fact that VCExpress is a win32 process is fooling cl into thinking i'm running an X86 machine? I think that's very possible, as the error states that it thinks i'm running X86... I'm not sure... I think cl is compiling code for X86 and VC is passing the X86 code on to the linker, which is expecting x64 compiled .obj's, but is getting X86 compiled obj's... I don't know, but that's what it seems like. and if that's true, then why can't it cross-compile, if everyone says you can cross-compile by other methods? It's all a ploy for more money to microsoft, if you ask me, because right now the only seemingly clean way to develop win64 apps is to purchase VS2k5 pro... wow... i'm just fed up with it all now. I wish they would hurry up and get gcc 4.0 working on MinGW...
confusedly yours,
fearan
Fearan
QUOTE(brewin @ Feb 20 2006, 03:50 PM)
http://msdn2.microsoft.com/en-us/library/9yb4317s.aspx

Read the note about the Express version.
*

ok... I don't have the MIDL Property Pages... what now?
wingrunr21
I'm pretty sure that you can't compile in 64-bit with the Express editions. You may be able to download the .NET 2.0 SDK and customize the compiler options for another compiler.
squid
I'm pretty sure you can, since I do it myself. Get the PSDK, open the build environment for windows x64 (retail), start VS2005 with the /useenv switch, and make sure the target machine under linker->advanced properties is set to default (NOT x86) for all projects in the solution.
wingrunr21
QUOTE(wingrunr21 @ Mar 3 2006, 07:36 PM)
You may be able to download the .NET 2.0 SDK and customize the compiler options for another compiler.
*



QUOTE(squid @ Mar 5 2006, 08:18 AM)
I'm pretty sure you can, since I do it myself. Get the PSDK, open the build environment for windows x64 (retail), start VS2005 with the /useenv switch, and make sure the target machine under linker->advanced properties is set to default (NOT x86) for all projects in the solution.
*


Which is what I said and Brewin said. But there ya go, full directions.
squid
The linker properties is the catch. Even after changing it you normally need to do a build->clean to flush out the old x86 .obj files because VS isn't always smart enough to do it.
allanmb
You need to set VC to compile using the x64 headers. Do this by setting two things, one of which has been touched on but I add it here for completeness:

1) Under Project Properties -> Linker -> Advanced -> Target Machine, make sure you have MachineX64 selected.

2) Under Build -> Configuration Manager -> Active Solution Platform, make sure you have x64 selected. If it is not there just select new, choose x64 as the platform and copy from the win32.

Voila!

HTH
Allan
Degski
QUOTE(allanmb @ Mar 8 2006, 02:48 PM)
You need to set VC to compile using the x64 headers.  Do this by setting two things, one of which has been touched on but I add it here for completeness:

1) Under Project Properties -> Linker -> Advanced -> Target Machine, make sure you have MachineX64 selected.

2) Under Build -> Configuration Manager -> Active Solution Platform, make sure you have x64 selected.  If it is not there just select new, choose x64 as the platform and copy from the win32.

Voila!

HTH
Allan
*


This only is available in the Pro version! To compile for AMD64, you'll need to install the PSDK (Platform System Development Kit Windows Server 2003 SP1 (free from M$) (this includes the NET Framework 2.0), but that's not the reason why it doesn't work! Install VC Express, Install PSDK, open a command prompt from the menu-options installed by the PSDK, open Winx64|Release (or debug if you want) and from the PSDK command prompt start the devenv.exe (or modify the .cmd file in the install directory of the PSDK) now VC Express opens and it appears that nothing has happened (the "dos" window should say that it targets Win64!)

Now, don't try to change the Win32 option in the configuration manager, this doesn't work, and in reality it doesn't matter, your environment points to the x64 compiler, VCExpress doesn't know that, and doesn't need to know, apart from the following!!!

In the linker->advanced options of your project set the target machine to -> Not Set. Now add to the linker command line the following -> /Machine:AMD64

This is working, if not, you're doing something wrong!!

Now write yor program, build, run! Enjoy.

BTW, if I'm not to clear try AMD: http://www.devx.com/amd/Article/21313
Fearan
Well thanks for all your help... sorry I haven't responded in a while. I got VS pro, and it's great. It does x64 compiling without a flaw. Very nice, and a lot easier.
Tweak
Someone named "charleswghk" suggested the following...

"An additional note:

Sometimes linker problem occurs like:

Linker Tools Error LNK2001
'unresolved external symbol __security_check_cookie '

and you could link it with bufferoverflowu.lib

http://download.microsoft.com/download/8/0...ryCTPReadme.htm

Kelvin Wong "
enderandrew
Would you will be willing to share your compiles?

I'd love to see more 64-bit apps for Windows.
mmoy
QUOTE(Fearan @ Mar 26 2006, 12:36 PM)
Well thanks for all your help... sorry I haven't responded in a while.  I got VS pro, and it's great.  It does x64 compiling without a flaw.  Very nice, and a lot easier.
*



Can you tell me where you bought it? I'm looking at getting another license
and would like to get a good price.

thanks,
michael
Fearan
QUOTE(mmoy @ Jun 4 2006, 07:43 PM)
Can you tell me where you bought it? I'm looking at getting another license
and would like to get a good price.

thanks,
michael
*

Well i didn't say I bought it... biggrin.gif
EdMaster
QUOTE(wingrunr21 @ Mar 3 2006, 06:36 PM) *
I'm pretty sure that you can't compile in 64-bit with the Express editions.


Oh, fortunately YOU CAN perfectly compile 64-bit from the IDE, debug, and even USE THE ASSEMBLER WITH ASSEMBLER DEBUGGING in Visual C++ Express 2005, provided that you have the right installation of the PSDK (Platform Software Development Kit).

Let's say that you have the PSDK already installed, and that you installed VC++ Express 2005.

Just like another fellow says in this thread, all you need to do is to open one of the environments that target 64 bits in the PSDK. From that command line, a simple "C:\.....\VCExpress /useenv" will start a VC++ IDE ready for 64 bit work, even though it is going to say Win32 all over the place. Do not believe that, and relax, because the IDE is going to use the CL and Linker for 64 bits.

You may have the problems of
Linker Tools Error LNK2001
'unresolved external symbol __security_cookie '

Linker Tools Error LNK2001
'unresolved external symbol __security_check_cookie '

For that, only include the library bufferoverflowU.lib according to what this guy says

Use the debugging options, debug a program, and open the "disassemble" and you'll see that you're AMD64.

To use also the assembler, in the PSDK it comes the ml64.exe that you need. You may trick the IDE into assembling AMD64 by copying in the same folder the ml64.exe file is to the name ml.exe, and do the following:

[Let's say you want to simulate the inline assembler: You can compile the files with assembly listing on (select in the C/C++ project options the Assembly With Source Code (/FAs)), then, you can remove the C/C++ source file from the project, and then] include the .asm [that the compiler generated], and when you try to include a .asm, VC++ will say that there is a default rule to manage .asm files. That default rule is basically Ok because ml.exe and ml64.exe have about the same command line options.

Then, when you do a build, the IDE invokes the ml.exe (which in reality is the file you copied ml64.exe) and assembles just fine.

Then, you can even have assembler source debugging just like in 32 bits.

Hope this helps

Try a reply if this message was good to you
mmoy
I used the PSDK before VS2005 came out and it's fine to use but if you eventually want to go with VS2005, you'd have to make changes.

I'm pretty sure that there are several switches not available in the PSDK.

And I think that there are some bugfixes in VS2005.

I still have some of my build pieces for PSDK but I'm thinking of just getting rid of it now.
netwave
http://msdn.microsoft.com/vstudio/vshome.aspx
Karpov Andrey
QUOTE(Fearan @ Feb 21 2006, 03:05 AM) *
------ Build started: Project: hellox64, Configuration: Debug Win32 ------
Linking...
.\Debug\hellox64.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
Build log was saved at "file://c:\Documents and Settings\Fearan Iluviathalion\My Documents\Visual Studio 2005\Projects\hellox64\hellox64\Debug\BuildLog.htm"
hellox64 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Linker Tool tries link together 32-bit and 64-bit object modules (obj-files). It is naturally impossible. Closely check up parameters of the project. Such situation often arises at converting the project created in VC6 at attempt to build the 64-bit version. When you create a new 64-bit configuration, there is copying parameters from 32-bit configuration. Visual Studio 2005 only changes some DEFINE and some keys. Visual Studio 2005 only changes number DEFINE and keys. And the parameters specifying on in addition link object modules and lib-files remain former.
See also: http://msdn2.microsoft.com/en-US/library/21ksa10x.aspx
Still I wish to warn trailblazers, that successful compilation and link a 64-bit code, it yet the end. I recommend carefully it to test. There can be errors in the most unexpected places.
For this theme I recommend will familiarize with: http://www.viva64.com/articles.php
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.