Search code examples
c++directx-9

How do I link d3dx9?


I compiled a DirectX program with g++ via the command line and it worked just fine. When I included d3dx9.h, I got the all too familiar "no such file or directory" message. As it turns out, the linker "cannot find -ld3dx9". I checked, and the necessary files are in their proper directories. The include and lib files are properly flagged. The compiler takes the -ld3d9 flag just fine, but apparently -ld3dx9 does not fly. I tried it in CodeBlocks and the same thing happened. It worked just fine and dandy for some fellow on YouTube. I must be missing something extremely obvious.

edit: Here is what I give the compiler. I'm on 64 bit Windows 7.

g++ Wrap.cpp winmain.cpp -o test
-IC:\ProgramFiles(x86)\MicrosoftDirectXSDK(June2010)\Include
-LC:\ProgramFiles(x86)\MicrosoftDirectXSDK(June2010)\Lib\x64
-ld3d9 -ld3dx9 -mwindows

and here's the includes in the file

#include <windows.h>
#include <d3d9.h>
#include <d3dx9.h>

Solution

  • Do you really have a directory named ProgramFiles(x86)? You should quote or escape spaces in the command. For example, something like this might work:

    g++ ... "-IC:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include"