Jump to content
  • Advertisement
Sign in to follow this  
Glordag

Suspected linking problem

This topic is 4053 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

<Skip down some for the question if you don't want to read the top.> Hello everyone. I'm sure this issue has been beaten into the dirt (I've seen several similar topics, but nothing addressing my issue particularly), but I'm having trouble finding a solution after googling around and looking over posts. I'm just now getting into DirectX programming. After looking for a suitable compiler, I had settled on Codeblocks. The reason for this is that the Express edition of Visual C++ doesn't have the Win32 Project template, and I seem to need this to do the Windows applications I'm working on. The book I'm reading (Beginning Game Programming: Second Edition) claims Dev-C++ isn't compatible with windows, either. After trying Codeblocks, I had no problems compiling the Windows code or even the DirectX that only requires the d3d9 library and header. Now, I've finally run into a problem. I'm working on the next step of DirectX in the book, which is simply loading a bitmap to the screen. As I'm sure you all know, this requires this use of d3dx9. After some tweaking around I got Codeblocks to seemingly integrate the d3dx9 library fine, and I've included <d3dx9.h> at the top of the code. The problem is, I'm getting the following error when using "D3DXLoadSurfaceFromFile": <---------------------Actual Problem/Question Here--------------------------> Switching to target: default Linking executable: C:\Documents and Settings\Bedford\My Documents\CodeBlocks\createsurface\CreateSurface.exe .objs\winmain.o:winmain.cpp:(.text+0x4d7): undefined reference to `D3DXLoadSurfaceFromFileA@32' collect2: ld returned 1 exit status Process terminated with status 1 (0 minutes, 1 seconds) <----------------------------------------------------------------------------> This occurs from the following call: result = D3DXLoadSurfaceFromFile(surface, NULL, NULL, "legotron.bmp", NULL, D3DX_DEFAULT, 0, NULL); result was simply defined in the same function like so: HRESULT result; From what I can tell, D3DXLoadSurfaceFromFile defaults to D3DxLoadSurfaceFromFileA if UNICODE isn't being used, which means that the d3dx9 header/library seems to be included as I thought. If that's the case, though, then why am I still getting an undefined reference? I'm very confused. Does anybody know what's wrong or have any suggestions? Any help is greatly appreciated. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
You should specify an import library that the linker should link to your executable. Somewhere in your project settings you should be able to specify which libraries are to be linked, add 'd3dx9.lib' to them.

I'm not familiar with your compiler, but if you switch to VS2005 I can tell you exactly what to do [grin].

Share this post


Link to post
Share on other sites
Well, that's what I did to solve the problem I had originally with the d3d9 library. The thing is, I tried adding "-d3dx9", "-ld3dx9", "-d3dx9.lib", and several other variations to my linker options, and that doesn't seem to be helping. I'm not sure if that's the proper (or only) way to import libraries to the linker, but it worked when I added "-ld3d9" for the d3d9 library. *boggle*

From what I could tell, VC++ 2005 express didn't even have the template for Win32 projects, and that wasn't going to suffice at all ): .

Share this post


Link to post
Share on other sites
I happen to use VS 2005 Professional, so I wouldn't know about the template thing. But many users here are using VS so they somehow solved it. I heard a lot of people mentioning you should download the Platform SDK as well, perhaps that contains the Win32 template.

Anyway... back to your problem.

I took a simple project and include <d3dx9tex.h> and put a call to D3DXLoadSurfaceFromFile() into it and indeed, I got a linker error as was to be expected.

Then I added the d3dx9.lib library to the linker input and suddenly it could link. So that's the one you need as well.

From your last reply I can deduce you're using some version of GCC to actually build your project, so perhaps you should try adding this setting:

-L<path to your lib-files> -ld3dx9

That path to your library files tells the linker where to find the .lib files... Try putting in the absolute path to d3dx9.lib at first.

Share this post


Link to post
Share on other sites
Quote:

The reason for this is that the Express edition of Visual C++ doesn't have the Win32 Project template, and I seem to need this to do the Windows applications I'm working on.

That's because you did not follow the instructions to download and install the Platform SDK. The SDK is a 400MB download; if that doesn't pose a problem, get it and use VS. The DX SDK is not written with mingw in mind, you might run into some very obscure problems down the line.

Share this post


Link to post
Share on other sites
Quote:
Original post by jpetrie
Quote:

The reason for this is that the Express edition of Visual C++ doesn't have the Win32 Project template, and I seem to need this to do the Windows applications I'm working on.

That's because you did not follow the instructions to download and install the Platform SDK. The SDK is a 400MB download; if that doesn't pose a problem, get it and use VS. The DX SDK is not written with mingw in mind, you might run into some very obscure problems down the line.


Ah, I see the Platform SDK now. I'll probably just go with that, and download the service pack while I'm at it. I completely missed the "Download Additional Components" step. I must have been sleepy or impatient when I was grabbing it (: .

Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!