Author Topic: Alright...DirectX again...  (Read 10679 times)

All0i5hu5

  • Guest
Alright...DirectX again...
« on: November 14, 2005, 08:20:34 pm »
I am still trying to get the DirectX Simple Sample project to compile:

My environment: Windows XP SP 2, Codeblocks RC2, C++ Toolkit 2003, Platform SDK, DirectX 9.0 SDK October, and .NET Framework SDK. All SDKs installed to default locations.

I was able to walk the project through the libraries and files, but am stumped as to what is causing the problem now. I created the project from new as a Win32 GUI application and then added the files: Simplesample.cpp, .fx, .rc, .jpg, and resource.h

I checked the project using Visual Studio .NET and the project compiles fine there.

**********************************BUILD LOG**************************************************************
Project   : Sample
Compiler  : Microsoft Visual C++ Toolkit 2003 (called directly)
Directory : C:\Documents and Settings\Aardvarkius\My Documents\Projects\ASample\
--------------------------------------------------------------------------------
Switching to target: default
RC.Exe  /I"C:\Program Files\Microsoft Platform SDK\Bin" /I"C:\Program Files\Microsoft Platform SDK\Include"   -fo.objs\SimpleSample.res SimpleSample.rc
cl.exe /nologo    /DUNICODE    /I"C:\Program Files\Microsoft DirectX 9.0 SDK (October 2005)\Samples\C++\Common" /I"C:\Program Files\Microsoft Platform SDK\Include" /I"C:\Program Files\Microsoft Platform SDK\Include\crt" /I"C:\Program Files\Microsoft DirectX 9.0 SDK (October 2005)\Include" /c SimpleSample.cpp /Fo.objs\SimpleSample.obj
SimpleSample.cpp
link.exe /nologo /subsystem:windows    /LIBPATH:"C:\Program Files\Microsoft Platform SDK\Lib" /LIBPATH:"C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib" /LIBPATH:"C:\Program Files\Microsoft DirectX 9.0 SDK (October 2005)\Lib\x86" /out:Sample.exe   gdi32.lib user32.lib kernel32.lib  .objs\SimpleSample.obj  .objs\SimpleSample.res   
SimpleSample.obj : error LNK2019: unresolved external symbol "int __cdecl DXUTGetExitCode(void)" (?DXUTGetExitCode@@YAHXZ) referenced in function _WinMain@16
SimpleSample.obj : error LNK2019: unresolved external symbol "long __cdecl DXUTMainLoop(struct HACCEL__ *)" (?DXUTMainLoop@@YAJPAUHACCEL__@@@Z) referenced in function _WinMain@16

A whole bunch of other library linker errors

OnDestroyDevice@CD3DSettingsDlg@@QAEJXZ) referenced in function "void __stdcall OnDestroyDevice(void *)" (?OnDestroyDevice@@YGXPAX@Z)
Process terminated with status 1 (0 minutes, 9 seconds)
52 errors, 0 warnings
*****************************************************************************************************

I guess it is a library causing the problem. But where?

My Codeblocks Setup is:
Settings -> Compiler -> Compiler Tab -> #defines Tab:
UNICODE

Settings -> Compiler -> Directories Tab -> Compiler Tab:
C:\Program Files\Microsoft DirectX 9.0 SDK (October 2005)\Samples\C++\Common
C:\Program Files\Microsoft Platform SDK\Include
C:\Program Files\Microsoft Platform SDK\Include\crt
C:\Program Files\Microsoft DirectX 9.0 SDK (October 2005)\Include

Settings -> Compiler -> Directories Tab -> Linker Tab:
C:\Program Files\Microsoft Platform SDK\Lib
C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib
C:\Program Files\Microsoft DirectX 9.0 SDK (October 2005)\Lib\x86

Settings -> Compiler -> Directories Tab -> Resource Compiler Tab:
C:\Program Files\Microsoft Platform SDK\Bin
C:\Program Files\Microsoft Platform SDK\Include

Settings -> Compiler -> Programs Tab -> Additional Paths Tab:
C:\Program Files\Microsoft Platform SDK\Bin

Any ideas? I have played around with using various libraries (the .NET library for instance), but apparently I am doing that wrong, or am still using the wrong libraries.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Alright...DirectX again...
« Reply #1 on: November 15, 2005, 10:58:43 am »
Hello,

I do not know if this can help, but I also have:

Settings -> Compiler -> Directories Tab -> Compiler Tab:

C:\Programme\Microsoft Visual C++ Toolkit 2003\include

Settings -> Compiler -> Directories Tab -> Resource Compiler Tab:

C:\Programme\Microsoft Visual C++ Toolkit 2003\bin

You can also check if your Microsoft Platform SDK is up to date.

If the project compiles fine in Visual Studio .NET (2003 I assume), then have a look at which kind of directories and project parameters are set and do the same with C::B.

Best wishes,
Michael

All0i5hu5

  • Guest
Re: Alright...DirectX again...
« Reply #2 on: November 17, 2005, 09:54:13 pm »
I have added both of those to no avail. Adding them or not adding them gives me 52 fatal errors of the type above. So there is no change.

My dxut.h file appears not to be pulling functions from the correct library. I haven't changed that, however. And this is a simple stock sample from DirectX SDK.

This is the latest DirectX SDK. I have all of the latest SDKs available, in fact, as I have installed them all from the web.

I checked VS 2003....there are a few differences, but only because VS 2003 has prerelease bins and includes that do not come with the standalone SDKs. Also, C++ Toolkit does not have debug support, as VS does. Other than that...everything pretty much looks the same. I am not sure where I went wrong, but I did somewhere.

Deleting the project and redoing it from scratch does not seem to help, either. I am at a loss now.

Offline Vampyre_Dark

  • Regular
  • ***
  • Posts: 255
  • Hello!
    • Somewhere Over The Rainbow...
Re: Alright...DirectX again...
« Reply #3 on: November 18, 2005, 08:52:03 am »
Are you adding the libraries to the build options?

dxguid
d3d
dinput.lib

All that crap, whatever the files are called.  :D

That's what your errors indicate.
C::B Wishlist
~BOYCOTT THE EVIL YELLOW BOXES~

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Alright...DirectX again...
« Reply #4 on: November 18, 2005, 10:58:10 am »
Hello,

Question to Vampire_Dark: Do you not have to add the extension .lib to the dxguid and d3d libraries (as you did for the dinput.lib)?

I have also tried myself 1-2 days ago with samples of DirectX (October 2005), but I have had problems with PCH, unicode, and several link errors. I have opened the project using VS C++ .NET 2003 and copied the required libraries in C::B (and looked at other project options too). Anyway, no success. I have also tried to add other libraries, but no results.

Anyway, did you tried to compile the DXUT project? I have tried, but with my samples it did not work :(.

To be honest MS Toolkit .NET 2003 give me much troubles than VS C++ .NET 2003 (may be some of my problems are a consequence of the fact that the MS Toolkit .NET 2003 does not come with debugging libraries). May be I have to try to use C::B with the compile/linker that come with VS C++ .NET 2005 Express Edition :).

Best wishes,
Michael

All0i5hu5

  • Guest
Re: Alright...DirectX again...
« Reply #5 on: November 18, 2005, 09:22:21 pm »
Ok folks....I solved it. It isn't that great of a solution, but I learned a ton along the way. I never had to mess with this stuff using MS Studio programs. Anyhow, for future posterity:

I had the October DirectX SDK, and used the sample browser to install SimpleSample example into my Projects directory.

I then imported the Visual Studio 2003 solution into Codeblocks using Project -> Import -> Visual Studo Solution. I then imported the 2003.sln

This brought in all of the necessary files from the simplesample project.

Now...for the setup of Codeblocks in order to make it work:
***************************************************************************
Settings -> Compiler
                     Microsoft Visual C++ Toolkit 2003 was selected as the default compiler.
                     Under Directories Tab -> Compiler Tab
                                                               C:\Program Files\Microsoft Platform SDK\include
                                                               C:\Program Files\Microsoft Platform SDK\crt
                                                               C:\Program Files\Microsoft DirectX 9.0 SDK (October 2005)\Include
                                                    -> Linker tab
                                                               C:\Program Files\Microsoft DirectX 9.0 SDK (October 2005)\Lib\x86
                                                               C:\Program Files\Microsoft Platform SDK\lib
                                                               C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib
                                                    -> Resource Compiler tab
                                                               C:\Program Files\Microsoft Platform SDK\include
                             Programs Tab -> Addtional Paths Tab
                                                               C:\Program Files\Microsoft Platform SDK\bin
                                                               C:\Program Files\Microsoft Platform SDK\include

Close the Settings Dialogs down. Now, right click on the Project, and go to Build Options:
You should see 3 Items under the project name:
       Debug
       Release
       Profile
Right click on each of these, and make sure you add these items (in addition to what already should be there) on the Linker Tab:
      user32.lib
      shell32.lib
      gdi32.lib
      advapi32.lib

(The rest of them should look something like this:  dxerr9, dxguid, d3dx9 (d3dx9d for debug), d3d9, winmm, and comctl32).

Those libs are found in the Platform SDK lib directory.

Make sure that under the Directories Tab -> Compiler Tab  You see Common (This reflects the common directory that is copied when you installed the project).

For your own projects, you should be able to get to the linker errors (not that you would want them) such as described as above:

IE: error LNK2019: unresolved external symbol __imp__SystemParametersInfoW@16 referenced in function "long __cdecl DXUTInit(bool,bool,bool,bool)" (?DXUTInit@@YAJ_N000@Z)

Go to http://msdn.microsoft.com/library/ and search for SystemParametersInfoW.

This will tell you which libraries you have to add to your Build Options.

Thanks for the tip, Vampyre.

The only thing that I might note is that I had, at that point, added those to my build options, but I added them using the Absolute paths to them rather than just typing in the name of the lib that I needed. I don't know if that made a difference. I went ahead and rebuilt the project using the import project function, whereas the first time I built the project using the Win32 App dialog from Codeblocks.

I hope this helps everyone, and was glad to be of service. I hope it is thorough enough, and if I come across anything else, I will add it.

PS: As noted by the directories above, the only downloads needed for this project was:
Codeblocks RC2
Microsoft Visual C++ Toolkit 2003
Microsoft Platform SDK
Microsoft DirectX 9.0 SDK (October 2005).
           
« Last Edit: November 18, 2005, 09:27:04 pm by All0i5hu5 »

Offline Vampyre_Dark

  • Regular
  • ***
  • Posts: 255
  • Hello!
    • Somewhere Over The Rainbow...
Re: Alright...DirectX again...
« Reply #6 on: November 18, 2005, 10:43:22 pm »
No, I don't need to add the extensions.

I haven't compiled the sample projects, I don't use them. I just include the proper includes where needed, and then I link to the libraries in my build options (like this)



Never had any troubles.

Now please stay tuned for our regularly anti-dx rant.
« Last Edit: November 18, 2005, 10:46:22 pm by Vampyre_Dark »
C::B Wishlist
~BOYCOTT THE EVIL YELLOW BOXES~

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Alright...DirectX again...
« Reply #7 on: November 20, 2005, 01:30:40 pm »
Hmm, I see.

I have had some problems when I did not add the extension .lib. C::B searched for .obj instead of .lib (http://forums.codeblocks.org/index.php/topic,696.0.html). So, personally, I prefer to add .lib, just for make it sure.

Best wishes,
Michael

Offline Vampyre_Dark

  • Regular
  • ***
  • Posts: 255
  • Hello!
    • Somewhere Over The Rainbow...
Re: Alright...DirectX again...
« Reply #8 on: November 21, 2005, 03:54:56 am »
Well I don't know what else to say. Are you including the proper headers in all your source files?

The above screenshot is my exact linking setup for my ogl/dx game, and it works fine. DX always worked fine.

The only things I can think of are that maybe you are compiling with gcc by accident or your linkig directories are setup wrong in your actual build options. Are you not linking to all the proper libraries? Do you have DXGUID linked first?
C::B Wishlist
~BOYCOTT THE EVIL YELLOW BOXES~

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Alright...DirectX again...
« Reply #9 on: November 21, 2005, 09:54:35 am »
Hello,

I had such experience while compiling/linking the RakNet (a network API) using MS Toolkit 2003, after having imported the solution with the C::B functionality. May be this is just a problem related to the imported solution. I will give a try without .lib extension. Anyway, some days ago I have given a try with the DirectX samples (e.g., Text3D), but without success (and the same sample did not compile with Visual Studio C++ .Net 2003 :?). Still have some work to do. Thank you for your suggestions.

Best wishes,
Michael