Author Topic: Creating 64bit code Tutorial  (Read 3720 times)

Offline Tjaalie

  • Multiple posting newcomer
  • *
  • Posts: 40
Creating 64bit code Tutorial
« on: August 28, 2007, 10:43:30 pm »
How-to compile amd64 code with Code::Blocks (by Tjaalie)

Requirements:
- Code::Bocks (just get a nightly build)
- Windows SDK (http://www.microsoft.com/downloads/details.aspx?familyid=C2B1E300-F358-4523-B479-F53D234CDCCF&displaylang=en)

Step 1) Make sure you have a nightly build because I don’t think that RC2 supports all the needed functionality to setup the compiler.

Step2) Install the Windows SDK, you can deselect all the .net stuff because we won’t be needing it.
*tip* If you deselect the documentation parts you reduce the download size to under 100mb.

Step3) Start Code::Blocks and go to ‘Settings->Compiler and Debugger settings’, then select ‘Microsoft Visual C++ 2005’ from the dropdown box and click the copy button. Now choose a name I used ‘Windows SDK x64’ but you can name it whatever you like.

Step4) Now with ‘Windows SDK x64’ as the selected compiler go to the ‘Toolchain executables’ tab and EMPTY the directory text box. Then click the ‘Additional Paths’ tab inside the ‘Toolchain executables’ tab. Remove the directory that goes to your Visual 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

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
Linker:
- C:\Program Files\Microsoft SDKs\Windows\v6.0\VC\LIB\x64
- C:\Program Files\Microsoft SDKs\Windows\v6.0\Lib\x64
Resource Compiler:
- None

Step6) Create a new project (console project) and select our new ‘Windows SDK x64’ compiler as the compiler to use. Now in the generated code add the following line:
Code
‘cout << “sizeof(void*) = ” << sizeof(void*) << ";" << endl;’
Hit the compile button and off we go when we execute the program it appears to have a 8byte long address (64 bits).

Remarks) When you create a gui application Code::Blocks starts yelling at you about the PSDK, in fact the Windows SDK is the PSDK for Vista so you don’t need it, so you need to fill in a bogus path when creating the app (e.g. ‘c:\’) and then later remove the entries to the PSDK in ‘Build Options…->Search Directories’. A new template would be cool but that’s something for another time.



Just something I have been strugling to find out, please tell me what you think about it. I don't know if this is the right forum becouse its not exactly a 'question' :D.

Tjaalie,

EDIT: Did some changes to the layout.
« Last Edit: August 28, 2007, 10:46:30 pm by Tjaalie »

Offline Tjaalie

  • Multiple posting newcomer
  • *
  • Posts: 40
Re: Creating 64bit code Tutorial
« Reply #1 on: August 29, 2007, 10:28:34 am »
Just ported my engine to 64 bit (a library and a sample) it isn't much yet (just an initialising d3d object with tga loader) but it works
like it should. I don't know if this is new but I couldn't find any info like this anywhere else so I hope it helps some people.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Creating 64bit code Tutorial
« Reply #2 on: August 29, 2007, 11:39:22 am »
You could try adding this article to the wiki, or else it will be burried here...
Use the same login credentials as the ones you use here.
Be patient!
This bug will be fixed soon...

Offline Tjaalie

  • Multiple posting newcomer
  • *
  • Posts: 40
Re: Creating 64bit code Tutorial
« Reply #3 on: August 29, 2007, 12:43:38 pm »
I wrote it to the wiki.
It can be viewed here.