Menu

D3D9 Linking Error (HELP)

2004-04-18
2012-09-26
  • Nobody/Anonymous

    Hello.

    I have recently started my journey into the world of DirectX, specifically Direct3D with DirectX 9. Well, I have created the code for the first tutorial "Creating a Device" that comes with the SDK.

    I have put all the .lib files into the "lib" folder in my Dev folder. I renamed them all by putting a "lib" in front of them and making their extension .a. As well, I have put all the DX .h files in the "include" folder of Dev. I am using Dev C++ 4.9.8.5, on Windows 2000, with the mingw compiler. At the top of my program I have typed "#include <d3d9.h>.

    When I run the program, I recieve the error:
    "[Linker error] undefined reference to 'Direct3DCreate9@4'"

    And my full compile log:

    Compiler: Default compiler
    Building Makefile: "C:\Direct 3D\Lesson 1\Makefile.win"
    Executing  make...
    make.exe -f "C:\Direct 3D\Lesson 1\Makefile.win" all
    g++.exe main.o  -o "Direct3D Template.exe" -L"C:/Dev-Cpp/lib" -lopengl32 -lglut32 -lglu32 -lglaux -mwindows ../../Dev-Cpp/lib/libd3d9.a

    main.o(.text+0x2c):main.cpp: undefined reference to `Direct3DCreate9@4'

    make.exe: *** ["Direct3D] Error 1

    Execution terminated

    Why is this happening?!?! Thanks for the help!

    BTW: I used to use OpenGL, but why are the files still listed there (ex. lglut32)?

     
    • Nobody/Anonymous

      Well, I downloaded the DevPackage for DirectX 9 that I found in a reply on another topic. However, know it just won't run. No linker error this time.

      Compile log:

      Compiler: Default compiler
      Building Makefile: "C:\Direct 3D\Lesson 1\Makefile.win"
      Executing  make...
      make.exe -f "C:\Direct 3D\Lesson 1\Makefile.win" all
      g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include/c++"  -I"C:/Dev-Cpp/include/c++/mingw32"  -I"C:/Dev-Cpp/include/c++/backward"  -I"C:/Dev-Cpp/include" ../../Dev-Cpp/lib/libd3d9.a 

      g++.exe: cannot specify -o with -c or -S and multiple compilations

      make.exe: *** [main.o] Error 1

      Execution terminated

      I think that "g++.exe: cannot specify -o with -c or -S and multiple compilations" is the problem. But what does it mean, and how do I fix it? Thanks!

       
    • Nobody/Anonymous

      I downloaded a DevPack found in a different topic for DX 9, and there is no linker error anymore. But it wont work due to a build error. Someting about g++.exe not working I beleive.

      Compile Log:
      Compiler: Default compiler
      Building Makefile: "C:\Direct 3D\Lesson 1\Makefile.win"
      Executing  make...
      make.exe -f "C:\Direct 3D\Lesson 1\Makefile.win" all
      g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include/c++"  -I"C:/Dev-Cpp/include/c++/mingw32"  -I"C:/Dev-Cpp/include/c++/backward"  -I"C:/Dev-Cpp/include" ../../Dev-Cpp/lib/libd3d9.a 

      g++.exe: cannot specify -o with -c or -S and multiple compilations

      make.exe: *** [main.o] Error 1

      Execution terminated

      Why is it not working?!?!? Thanks for the help!!!

       
    • Wayne Keen

      Wayne Keen - 2004-04-18

      "BTW: I used to use OpenGL, but why are the files still listed there (ex. lglut32)?"

      Did you mean "where", not "why"?

      If you look in the threat titled "The Forum FAQ - Please Read First", there are some step by step directions in there on setting up and running Glut.

      "g++.exe: cannot specify -o with -c or -S and multiple compilations"

      This tells you exactly what your problem is.  You need to look at your compile options, because you will notice in your log:

      g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include/c++/mingw32" -I"C:/Dev-Cpp/include/c++/backward" -I"C:/Dev-Cpp/include" ../../Dev-Cpp/lib/libd3d9.a

      You have -o and -c both there.

      Wayne

       
    • Nobody/Anonymous

      Well, I can compile well with d3d9...
      My d3d9.h is in c:\DXSDK\Include and d3d9.lib is in c:\DXSDK\lib
      No need to rename files, leave them as they are...
      Then you have to add -fvtable-thunks in your compiler options and -ld3d9 in liker options.
      Make sure the path to d3d9.lib is in include paths list for your project.
      everything will build well, I think.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.