locked
Compiling for 64 bit on a 32 bit machine

    Question

  • Hi,

    I am running Microsoft Visual Studio 2005 Pro on a 32 bit version of XP Pro.

    Is it possible to compile a dll for my C code for a 64 bit system?

    I can get a dll in the release file, but I assume it is for a 32 bit system since that is what it says in my Solution Platforms field and I cannot change it to be 64 bit.

    I am very new to programming so thanks in advance for your help and patients.

    -J Brake
    Tuesday, March 20, 2007 5:14 PM

Answers

  • Please make sure that x64 bit compilers are installed on your 32-bit machine. Not installed by default.

     

    Goto Add/Remove programs, select Visual Studio, Change, Add/Remove features and add x64 compilers from C++ node. After installing x64 compilers, you should see appropriate options under Platform and shoudl be able to build x64 projects on 32 bit machine.

    Monday, July 09, 2007 2:58 PM

All replies

  • if you can change the project to 64bit ,

     

    it may be you have not installed the 64bit of Visual studio 2005, it is contained in the VS2005 pro. but it must be installed selectedly. so you must choose custom install for vs2005.

    Thursday, March 29, 2007 5:10 AM
  • Yes, you should and it is as easy as changing the project build type to 64bit. If this is native code that is. For .NET code

    things are different because it supports "agnostic" which is clever and means that an assembly will operate as 32-bit OR 64-bit depending

    upon the platform it runs on.

    For native code rememebr that a) You may need to install 64-bit features of VS 2005 that are not installed by default and that you cannot debug native

    64-bit code in an interop setting.

    Thursday, March 29, 2007 3:31 PM
  • There are a few important things to call out here.  Using the 32bit VS 2005 you can build and debug native and managed 64bit applications.

     

    Before you are able to do any building, or debugging you have to install the 64bit cross compilers.  This was a step during the initial install, you can run "Add/Remove" programs to install these now.

     

    For building, Hugo is correct that by default all managed code is "agnostic" or MSIL.  This means that it will run as on both 32bit and 64bit platforms.

     

    Debugging 64bit applications from VS 2005 is done via remote debugging.  So you will need to start the 64bit remote debugging proxy on the machine that you wish to debug.

     

    Hope that this helps.

     

    Jeff

    Thursday, March 29, 2007 4:38 PM
  • Hi Jeff

    Can you elobaroate on debugging?

    I have and regularly do, debug managed code running as 64-bit on XP, Server 2003 and Vista 64-bit OSs.

    I do this just the same way that I would debug 32-bit managed code running on 32-bit OSs.

     

    Am I missing something?

     

    H

    Thursday, March 29, 2007 7:07 PM
  • Wow thanks for all of the responses.

    So when I make a new project I can select the platform x64 and x86.  I select x64 and it works great.

    I am working with some legacy C code.  When I go to select the platform the only option is Win32.

    When I go into <NEW> in the combo box The only options I get for a new platform are:
    Pocket PC 2003 (ARMV4)  -and-
    Smartphone 2003 (ARMV4)

    with copy settings from Win32

    I think it should say Any PC in Copy settingg from:

    Is there something that I can do to make this compile for 64 bit?  Or is this tied to the project in an unchangeable way.

    Thanks in advance,
    JB
    Wednesday, April 11, 2007 3:41 PM
  • Hello JB,

    I am also trying to compile 64bit on 32bit machine. I am also facing the same problem. I would like to know which project did you select when you got x64 and x86 options? I tried all types of project. I am not getting any option to select x64 or x86.

     

    Thanks,

     

    Thursday, June 21, 2007 5:19 AM
  • It is possible to get windows xp 64 bit from microsoft site (trial download) and run it in VMWare with 64 bit option in a 32 bit system. I think it should be a help great to debug.

     

    --

    Sincerely,

    Maruf Maniruzzaman,
      Software Engineer,

    KAZ Software Limited,

    Dhaka, Bangladesh.

    http://www.kaz.com.bd

    http://www.kuashaonline.com

     

    Wednesday, July 04, 2007 6:37 AM
  • Please make sure that x64 bit compilers are installed on your 32-bit machine. Not installed by default.

     

    Goto Add/Remove programs, select Visual Studio, Change, Add/Remove features and add x64 compilers from C++ node. After installing x64 compilers, you should see appropriate options under Platform and shoudl be able to build x64 projects on 32 bit machine.

    Monday, July 09, 2007 2:58 PM
  • I would like to add something here that may not be obvious.

     

    Mixed mode debugging (stepping between managed and unmanaged code) is not supported for x64 code. However that does NOT mean you cannot do mixed mode debugging under a 64-bit OS.

     

    It is not the OS that is the restriction, it is whether the debugged code is 64-bit or not.

     

    So if you have a mixed mode app (managed code + 64-bit unmanaged, say some 64-bit DLL) then you cannot do mixed mode debugging.

     

    BUT if you rebuild the code so that it is 32-bit (and force the managed code to be 32-bit too) then you can do mixed mode debugging, even if the OS is 64-bit (XP, Vista etc).

     

    Since .NET assemblies can be built as 'Any CPU' (i.e. 'agnostic') I'd be fascinated to learn if there is a way to force an agnostic assembly to run as 32-bit on a 64-bit OS. I assume that the CLR somehow decides that if it sees an agnostic app is being started, to run it as 32-bit or 64-bit depending on the OS.

     

    It wd be nice to have a project/solution setting called 'Run as' that could be 'default', '32-bit' or '64-bit' thus making it easier to run code as 32-bit and hence facilitate mixed mode debugging on 64-bit OS.

     

    Regards

     

    Monday, July 09, 2007 3:18 PM
  • Hi


    I am having a  x86 targetted machine application which is built in VS2005 on windows 2000 build server. I am trying to run it Onto Windows 2003 x64 box.

    I have disabled manifest file embedding by linker option and I embed manifest file as a post build step. I have given reference to x86 CRT into my manifest files.

    It also has a dotNet2.0 dependent C++ dll which fails to run on Windows 2003 x64 box. I am shipping all the CRT dlls alongside my application which have similar CRT version as that of referred by manifest file embedded in the application.

    The application runs fine on Windows 2000 NT, XP. But fails to run on Windows 2003 x64 box and I get error "The application failed to initialize properly"


    Is there any setting / modification I need to do in manifest in order to run it on both 32 & 64?

    • Proposed as answer by cssihyd Friday, September 19, 2008 6:41 AM
    Monday, September 01, 2008 8:50 PM
  • Yes, don't reference x86 DLLs in the manifest for a 64-bit program.  processorArchitecture = "amd64"
    Hans Passant.
    • Proposed as answer by cssihyd Friday, September 19, 2008 6:40 AM
    Tuesday, September 02, 2008 1:24 AM
  • No but I want to target x86 architecture and its built on x86 architecture only and I am shipping x86 CRT alongwith my binaries. Should this not run on x64 windows 2003 server?
    All I want is to run my x86 targetted app to run on x64 machine.
    I think its right assumption that 32bit app should also run fine on 64bit architecture. But I don't know if there are any special settings for this in manifest for apps built off VS2005
    • Edited by rahul karurkar Tuesday, September 02, 2008 6:58 AM explaination about what app is
    Tuesday, September 02, 2008 6:51 AM