Skip to main content
gamedev.net
🔒 Locked

getting directx to work on dev-cpp

Started by 2122 19 replies 2.9k views
Original Post
2122
2122
I've looked in the faq, and searched the forums, but I can't find out how to fix the linker error I get when I try to compile one of the directx sample programs that came with the book. It says "undefined reference to 'direct3dcreate9@4'" what do I do about this?
Sol462
Sol462
That's because you aren't linking to the Direct3D libraries in your project settings. There is (may be outdated) a devpack for DirectX9. Look in the Tools menu (or something similar).
Not sure if it worked as it's been awhile since I used Dev-C++.
2122
2122
I've set the project options to include every library file, and include file that came with directx, and I still get the same linker error. What's a devpack?
darookie
darookie
Quote:
Original post by 2122
What's a devpack?

Look here.
Also, Dev-C++ hasn't been updated for 17 months (version 5 is still beta since Feb. 2005). It might be discontinued or at least put on ice. I'd suggest looking at Code::Blocks and trying that out, too. Maybe you'll like it even better than Dev-C++.

Good luck!
Sol462
Sol462
C::B can even use devpacks as well. But if you decide to switch then I guess it would be better to use the Visual C++ compiler with the DirectX SDK.
Muhammad Haggag
Muhammad Haggag
Quote:
Original post by 2122
I've looked in the faq, and searched the forums, but I can't find out how to fix the linker error I get when I try to compile one of the directx sample programs that came with the book. It says "undefined reference to 'direct3dcreate9@4'" what do I do about this?

The DirectX SDK provides libraries in the new lib format. Perhaps MinGW GCC (which DevCPP uses) hasn't supported it yet. Check this article.

2122
2122
Ok, I got the free version of the microsoft visual c++ compiler. It works fine, but I have no clue how to set up direct x to run with it.
Sol462
Sol462
First you need to install the Microsoft Platform SDK to be able to make Win32 projects. Then, you must install the DIrectX9 SDK.
After all that you just need to configure the project directories and allow windowed Win32 projects to be enabled.
2122
2122
Is this what I want?
http://www.microsoft.com/downloads/details.aspx?FamilyID=d8462378-2f68-409d-9cb3-02312bc23bfd&DisplayLang=en
Sol462
Sol462
This is what you need to install. Not too sure what it was that you found.
That's the web install. There is also a full download if you're inclined. Alternatively you can also buy the CD but it's not necessary.

Once that's installed you need to change a few things in some script, but it's been so long that I can't remember the specifics. A quick Google search helped me on that one.
Dave Hunt
Dave Hunt
Shouldn't direct3dcreate9 be Direct3DCreate9?
Sol462
Sol462
Hmm, didn't notice that. In that case his error must be caused by a single caps mistake.
Was that the only error or were there more?
2122
2122
Thats the only error, and I typed it into the forum wrong it is "Direct3DCreate9@4". I left out the caps by mistake.
2122
2122
I got the SDK and followed the instructions for setting it up, and tried the program that opens a blank window. I get three error when I try to build it.
error C2731: 'WinMain' : function cannot be overloaded
error C2440: '=' : cannot convert from 'const char [15]' to 'LPCWSTR'
error C2664: 'CreateWindowExW' : cannot conver parameter 2 from 'const char [15]' to 'LPCWSTR'

This is on the visual c++ compiler.
Dave Hunt
Dave Hunt
Go into Project/Properties, select General, and change "Use Unicode Character Set" to "Not Set" (or "Use Multi...", I can't remember which or if it matters).
2122
2122
Bot not set and multi give me 11 linker errors. Unicode gives me 3 errors.
Sol462
Sol462
Sometimes that happens for me, so I just cast the string to an LPCWSTR and it works fine.
For the WinMain error, was the did you select the Windows Application option when you made your Win32 project? So far that's the only explanation that I can think of at the moment, unless you gave the wrong arguments to the WinMain function or something.
2122
2122
I picked the Win32 console application, that was the only thing listed under win32. The code is directly from the cd, so unless the cd has it wrong it should be ok. What string do I change to LPCWSTR?
Sol462
Sol462
After you install the Platform SDK you need to remove a couple of comments from some script, enabling the Win32 windowed option in the application settings (when you first make your project). The code from your book should be fine as is.
Casting every string (or at least the ones that gave errors) to an LPCWSTR should keep the compiler happy. I can't remember if it was Unicode or Multibyte that didn't need a cast.
2122
2122
I got the window application to work. It makes an empty window just like the program I got from the book, but it's code is alot different, it doesn't even use the same include files or anything, and it has a bunch of resource files. Is that the way it's supposed to be?

Edit:
I got it to work with the code from my book too. Now that that's set I'm going to try to set up the directx stuff too. I think the book has instructions for this.

[Edited by - 2122 on July 10, 2006 3:09:02 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.