views:

307

answers:

3

I recently got Visual Studio on a new computer, and to set up DirectX on it, I went to Tools>Options>Projects and Solutions>VC++ Directories and under Library Files made a new entry C:\Program Files\Microsoft DirectX SDK (August 2009)\Lib\x86

and now ran a test program (essentially just initialized DirectX) and it worked fine. However, if I change ...\Lib\x86 to ...\Lib\x64, than I get a linker error that Direct3DCreate9 is undefined:

1>main.obj : error LNK2019: unresolved external symbol _Direct3DCreate9@4 referenced in function "void __cdecl init(void)" (?init@@YAXXZ)
+1  A: 

The x86 libraries are for 32-bit applications, and the x64 libraries are for 64-bit applications.

You can see which platform you are targetting in Visual Studio's Configuration Manager. Unless you have a good reason, you should be writing 32-bit applications, since 64-bit apps will require the 64-bit version of Windows to run.

interjay
A: 

Well the simple answer is that the x86 libraries are for 32 bit operating systems and the x64 libraries are for 64 bit operating systems.

Simply changing the DirectX library linked to will produce an error as you are (in all probability) trying to link your 32 bit code to the 64 bit library. You will need to compile your code to target 64 bit operating systems to get this to link successfully.

ChrisF
The system you are *running* doesn't matter. On 32-bit systems, you can still use the Visual C++ cross-compiler for 64-bit, producing a 64-bit application, linked to 64-bit libraries. You will be unable to test that application on your computer, though. Heck, I can compile 32-bit (and 64-bit since recently) Windows applications from Linux.
Nicolás
@Nicolas - good point. I'll update my answer.
ChrisF
A: 

The x64 folder contains the library files for the AMD64 platform (Windows 64 Bit). You need to compile your application for 64 bit, too. Also, you need the 64 bit version of Windows to run the produced executable.

Alexander Gessler

related questions