Visual Studio 2010: Direct X Lib link problem

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Visual Studio 2010: Direct X Lib link problem

      I was wondering if anyone might know why when I try using direct x i keep getting a link error until i explicitly tell it to include the d3d11.lib using #pragma comment(lib, "d3d11l.lib"). I added the Include and Lib directories to the project directories yet it still gives me this dumb error.
      - Matt G.
    • Because you have to specifically link all your static library's, it's not enough to just add the directory. I never use Dynamic library's except what is already linked through other statics, but I imagine it is the same.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • Yeah thats the way I link to, I don't like using pragmas at all
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • I personally like using the #pragma comment(lib, "blah.lib") solution since it tends to simplify configuration issues. All that is needed in the project configuration is to include the directories for includes and libs, and the #pragma takes care of specifying which library is actually needed. Add a #ifdef _DEBUG conditional compile to the code and you can specify a debug library over a release one.

      GCC4 does this, and a happy side effect of it is that almost 100% of the configuration settings are exactly the same for all build flavors. This REALLY makes managing the project configuration a lot easier, and also less error prone.
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • I didn't like the use of #pragma's at first because I thought it muddied up the project and didn't like having linked libs potentially defined in multiple places. I've since come around and have started switching my personal projects over to the #pragma method. It really does make life easier, just make sure you're consistent about where you link everything.

      -Rez
    • EDIT: Moving this post to another Forum as I don't think this is the best place for it.

      Hey guys, I'm a software engineer who has finally decided to follow his dreams and move into game development. Wooo!

      I'm currently reading the 4th edition of your book and absolutely love it. I made it to the 3D Math section and decided before I went any further that I'd start over and build a prototype game engine as I went (using the GCC4 code base as an example).

      For the last week I've been running into DXUT compile-time issues and I've finally given up trying to figure it out for myself. I'm really demoralized at this point and was hoping someone could lend a hand.

      The engine project (static library) has the 3 DXUT include directories referenced in the "Include Directories" and compiles just fine.

      The game project (Win32 App) references a "Lib" directory in it's "Library Directories" poject configuration containing the static libraries from the engine project mentioned along with the static libraries from the 3 DXUT projects (I built them locally). I've also included my machine's DXSDK Lib x86 directory.

      However this project doesn't compile as it gives me roughly 30 or so unresolved external symbol errors all dealing with directx. What's odd is that these unresolved symbols look to be standard directx methods used by DXUT (for example the DXUTOPT.obj file can't resolve _DXTraceW).

      (One more thing, I've only linked the dxut.lib and dxutopt.lib libraries as those are all that were needed by the GCC4 code base and I linked them using pragma comment lib. Something else that's weird is that when I search all files in the GCC4 code base for "pragma comment", it finds a bunch in 3rdParty\DXUT11 while my solution doesn't seem to search those directories.)

      Any thoughts? Thanks!
      -bullgoose

      The post was edited 4 times, last by bullgoose311 ().

    • Are you including the DirectX libs themselves? Can you copy & paste the exact errors you're seeing in the output window?

      -Rez
    • You mean in the "Linker -> Input" configuration settings? No I've only included the engine's static library there (using GCC4 code base as an example). Here's 2 examples of the 26 errors I'm getting but all of them are similar (and again I really appreciate the time I know you guys are busy, trying to get my code up into a repository as we speak)...

      Error 5 error LNK2019: unresolved external symbol _DXTraceW@20 referenced in function "long __stdcall DXUTTrace(char const *,unsigned long,long,wchar_t const *,bool)" (?DXUTTrace@@YGJPBDKJPB_W_N@Z) C:\Development\Repository\Testudin\Source\TestudinGame\dxut.lib(DXUTmisc.obj) TestudinGame (Visual Studio 2010)

      Error 8 error LNK2019: unresolved external symbol _D3DXSaveSurfaceToFileW@20 referenced in function "long __cdecl DXUTSnapD3D9Screenshot(wchar_t const *)" (?DXUTSnapD3D9Screenshot@@YAJPB_W@Z) C:\Development\Repository\Testudin\Source\TestudinGame\dxut.lib(DXUTmisc.obj) TestudinGame (Visual Studio 2010)
      -bullgoose
    • No worries, it's just hard to debug linker errors through a forum. ;)

      I think I know what the problem is. DXUT doesn't link DirectX for you by default, you need to #define DXUT_AUTOLIB before your dxut.h #include if you want it to do this. Otherwise, you have to link them yourself.

      You can see where we define it in GameCodeStd.h around line 101. You can also see where DXUT will link them around line 35 of DXUT.h (including the preprocessor logic to do it).

      -Rez
    • Rez you are the man! I've been trying to copy over only what I think I need at the time from GCC4, but I should probably stop making those assumptions considering I'm brand new to DirectX and fairly new to c++.

      Thanks for the help and getting back to me so soon. I'm enjoying the forums and learning a lot so I'll definitely be seeing you around.
      -bullgoose
    • Excellent! I'm glad it worked!

      The forums are small and Mike & I get busy with work, but we're always willing to answer any questions you have. There's no question too big or small for this forum, so feel free to ask away. :)

      Let me know if you have any more questions.

      -Rez
    • Hi Everyone!

      I am new as well to c++, and have some experience to c# and web development, but like most on this forum I am looking to get into game development! I have a similar issue with dxut not loading. I have posted the error below, but what throws me off is I am using the sample code on the google code base (ive only downloaded it on my desktop, and moved it over to my laptop, but it worked on my desktop). It might be a newb mistake but any help is appreciated :).


      gamecodestd.h(105): fatal error C1083: Cannot open include file: 'dxut.h': No such file or directory

      P.S. #define DXUT_AUTOLIB is in there before the include to dxut

      The post was edited 1 time, last by Fuzzybritchiz ().

    • Either the header file isn't on your disc, or you need to add the folder it is in to your search directories.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • Hi mHolly519,

      Thank you for your quick response! I can physically bring up the dxut.h file that is located in the GameCode4_2010 project under the external dependencies folder. So by my logic if i can open the file it seems to be some type of linking issue, or maybe the directory is off(from going from my desktop to my laptop since the drives are different?). Again I'm kinda stumped because I'm new to how dependencies work in c++ projects vs. c# :/.

      P.S. sorry for sounding again newbish, but what do mean exactly by search directories? How would I add to it?

      The post was edited 1 time, last by Fuzzybritchiz ().

    • I have stopped using Windows so I don't have access to visual studio at the moment, but you will want to right click your project and go to project settings, it will likely be under the C++ tab on your left somewhere.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • Hey everyone thank you so much for all the information! Kaykry, after using some of the pointers you mentioned I noticed in the Include Directories since i changed file paths, my references were all going to non-existing folders. Now my only problem, is when building its throwing an error saying that the TeapotWars_2010Win32Debug.exe.embed.manifest isnt found, its trying to reference the old directory from my desktop... sounds like another project setting.
    • Not entirely sure - but I found this:

      stackoverflow.com/questions/41…le-network-path-not-found

      Do you have a drive, like "D:\" in your project paths?
      Mr.Mike
      Author, Programmer, Brewer, Patriot