Compiling 64-bit programs using codeblocks (the compiler is just the Windows SDK)

Source: Internet
Author: User
Tags visual studio 2010

Demand:

-codeblocks using nightly version;

-windows SDK (I use 6.0A, that is, Microsoft for Vista, because this is relatively small, you can choose another version but there are 64-bit compilers.) He is also suitable for xpsp2 and above but to install. net2.0 above to run) corresponding link

: http://download.microsoft.com/download/4/2/6/42684501-9ec5-43dd-9dfe-c8c9dfa6a66f/6.1.6000.16384.10. Windowssdk_vista_feb2007update_rtm. Dvd. Rel.iso

Step1) Make sure you had a nightly build because I don ' t think that RC2 supports all the needed functionality to setup the Compi Ler.

Nonsense, it's not that.

STEP2) Install the Windows SDK, you can deselect all the. NET stuff because we won ' t be needing it.

To install winSDK, I only selected three developers Tools->window Vista Headers and libraries. Others were disturbed.

Step3) Start code::blocks and go to ' Settings->compiler and Debugger Settings ', then select ' Microsoft Visual C + + 2005 ' from T He dropdown box and click the Copy button. Now choose a name I used ' Windows SDK x64 ' and you can name it whatever your like.

In the CB inside the compiler settings, select, vc2005, I chose the vc2005/2008 (the new CB version is the same), in the end, or manually modified. Nonsense not to say, the set just said to copy a new, and then casually a name, I was wnsdkv6x64.

Step4) Now with ' Windows SDK x64 ' as the selected compiler go to the ' Toolchain Executables ' tab andEMPTY the directory Text box. Then click the ' Additional Paths ' tab inside the ' Toolchain Executables ' tab. Remove the directory, the goes to your Visua L C + + 2005 install dir not the debug one and add the following directory ' s:
-C:\Program Files\Microsoft Sdks\windows\v6.0\bin\x64
-C:\Program Files\Microsoft Sdks\windows\v6.0\vc\bin\x64

He said start setting up the cross-compiler toolchain program (no tube, the English version is ' toolchain executables ' this tag, says put

This control is emptied, and then the following two directories are added to the Additional Path tab in the additional paths below, but the original one is deleted by default. The path to be added is as follows:

Note: If you are installing by default, you can use the path above.

%yoursdk%\bin\x64 (since I installed myself following the above installation in this directory, I did not set, my version is not the same as his?) But I did compile the pass.)

%yoursdk\vc\bin\x64


Step5) Now go to the ' Search Directories ' tab and remove all items under the ' Compiler ', ' Linker ' and ' Resource Compiler ' tabs. And then add the Following,compiler:
-C:\Program Files\Microsoft Sdks\windows\v6.0\vc\include
-C:\Program Files\Microsoft Sdks\windows\v6.0\include

Now go, position No. 0 in the figure, add the directory or custom path to the Number 1th tab.

%yoursdk%\vc\include

%yoursdk%\include

Number 2nd linker fill in the following:

Linker:
-C:\Program Files\Microsoft Sdks\windows\v6.0\vc\lib\x64
-C:\Program Files\Microsoft Sdks\windows\v6.0\lib\x64

or custom catalog fill in:

%yoursdk%\lib\x64

%yoursdk%\lib\vc\lib\x64

Number 3rd does not need to fill in, because the SDK does not have ...

Resource Compiler:
-None

Step6) Create a new Project (console project) and select our new ' Windows SDK x64 ' compiler as the compiler to use. Now on the generated code add the following line:

    • cout << "sizeof (void*) =" << sizeof (void*) << ";" << Endl;
Hit the compile button and off we go. When we execute the program it appears to has a 8byte long address (up to bits).

Basically finished, this is the test, he just test the console program can be correctly compiled, anyway I have compiled, look at the picture:

Use the wizard to create a new console project,

And then you can compile it.

No error: Shown below:

I also used the Win32 Wizard to create a standard Win32API window,


It's definitely a 64-bit program. The other has not tried, the next is the use of ms2010 compiled AMD64 tutorial, it should be very easy, is because do not want to use ms2010 so large volume of his, who want to try it, he used the Express version originally compiled AMD64, of course, to install winSDK, The latest vs2012 is said to have no need to install the Direct SDK, not known.

The following instructions would allow your to compile 64-bit code using Microsoft's VC compiler (with the Windows SDK) . Requirements:
-Code::bocks (at least as of 2012-07-23 the nightly build worked) [2]
-microsoft Visual C + + Express (or better) [3]
-microsoft Windows SDK v7.1 (earlier versions might not work, later version would probably work but directories would change ) [4]

Step 1) Install Visual Studio 2010.

Step 2) Install Windwos SDK.

Step 3) Install code::blocks following instructions listed in nightly Build forum.

Note:prior to setting up code::blocks for 64-bit compiling, and you could need to set the MSbuild environment to x64. This can is done my running the command:
"C:\Program Files\Microsoft Sdks\windows\v7.1\bin\setenv.cmd"/x64

Step 5Run the new installation for the nightly build of code::blocks. It should auto-detect your installed compilers, including the recently installed Visual C + + 2010.
Step 6) Once Code::Blocks Open the ' Global Compiler Settings ' (Settings->compiler ...). Select ' Microsoft Visual C + + 2010 '.
Now under the ' toolchain executables ' Tab change the Compiler ' s installation directory to:
C:\Program Files (x86) \microsoft Visual Studio 10.0\vc\bin\amd64
Note:if installed VC to a different directory this path would change. The important part is the and the '. \bin\amd64 ' directory.

While still in the ' Toolchain ... ' tab, click on ' Additional Paths '. Add the following:
C:\Program Files\Microsoft Sdks\windows\v7.1\bin\x64
C:\Program Files\Microsoft Sdks\windows\v7.1\bin
C:\Program Files (x86) \microsoft Visual Studio 10.0\Common7\IDE

Next you need to add the x64 includes and Lib file.
Under the ' Search Directories ' tab add the following to the Compiler search path:
C:\Program Files\Microsoft Sdks\windows\v7.1\include
C:\Program Files (x86) \microsoft Visual Studio 10.0\vc\include
Note:the Windows SDK directory should be listed first

Now add the following to the Linker search path (in this order):
C:\Program Files (x86) \microsoft Visual Studio 10.0\vc\lib\amd64
C:\Program Files\Microsoft Sdks\windows\v7.1\lib\x64
C:\Program Files\Microsoft Sdks\windows\v7.1\lib
C:\Program Files (x86) \microsoft Visual Studio 10.0\vc\lib

You should now is able to compile x64 code using VC (Express).

Please look at the original http://wiki.codeblocks.org/index.php?title=64Bit_Windows

Compiling 64-bit programs using codeblocks (the compiler is just the Windows SDK)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.