4

My OS is 64Bit Windows 7.
I wanted to build the DirectX Sample in C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\Direct3D10\Tutorials\Tutorial02. but when I build error occured with fatal error

LNK1104: 'winmm.lib' can't open the file.

I reinstalled Direct SDK, but no change. I also added the path (include, lib) to the settings.

If I remove 'winmm.lib' from the project settings, 'comctl32.lib' can't be opened. both libs were already present in properties>Linker>Input.

How can I solve this problem?

Werner Henze
  • 16,404
  • 12
  • 44
  • 69
Se Cheol Park
  • 49
  • 1
  • 1
  • 3
  • Where did you add the pathes? Did you check that winmm.lib is present on your hard drive? – Werner Henze Nov 05 '14 at 16:25
  • It should be in `C:/winows/system32` add this path to your library pathes – j-p Nov 05 '14 at 16:25
  • Those (both) are Windows SDK libraries: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib or around. – Roman R. Nov 05 '14 at 16:25
  • 2
    It will certainly not be in `C:/winows/system32` I do not have a single .lib file at all in this folder. Maybe you are thinking about .dlls. – drescherjm Nov 05 '14 at 16:41
  • `LNK1104: 'winmm.lib' can't open the file.` Are you mixing x86_64 and x86? Remember you can not use 64 bit libraries in 32 bit applications or 32 bit libraries in 64 bit applications. – drescherjm Nov 05 '14 at 16:45
  • @RomanR. right, the sdk should do the trick..., switched to linux for a long time ;-) – j-p Nov 05 '14 at 21:59

3 Answers3

4

Just put the line below in stdafx.h

#pragma comment(lib, "winmm.lib")
Enamul Hassan
  • 5,266
  • 23
  • 39
  • 56
Rokman
  • 61
  • 2
  • I was getting "LNK2028 unresolved token (0A00002D) extern C ..." messages when starting a project that used functions from winmm.dll. Adding the "#pragma comment ..." to add the reference to winmm.lib as above fixed the issue. – Kieron Hardy Apr 19 '18 at 19:56
2

winmm.lib isn't part of the DirectX SDK but is part of the Windows SDK.

Latest Windows SDK versions were also heavily reorganized but it includes the library you're looking for.

Marco A.
  • 43,032
  • 26
  • 132
  • 246
1

If you are trying to build any of the legacy DirectX SDK samples with VS 2012 or VS 2013, you need to modify the include/libs paths per the instructions on bottom of the page on MSDN. The most important change is that you must reverse the Include/Lib path order:

For VS 2010 it was:

$(DXSDK_DIR)Include;$(IncludePath)

$(DXSDK_DIR)Lib\x86;$(LibraryPath) or $(DXSDK_DIR)Lib\x64;$(LibraryPath)

For VS 2012/2013 it has to be:

$(IncludePath);$(DXSDK_DIR)Include

$(LibraryPath);$(DXSDK_DIR)Lib\x86 or $(LibraryPath);$(DXSDK_DIR)Lib\x64

Of course a better option is not spend time learning the older Direct3D 10 API at all, and use the latest Direct3D 11 Win32 desktop tutorials on MSDN Code Gallery. In fact, I've posted many of the legacy DirectX SDK samples there so they work fine with VS 2012/2013 Express for Windows Desktop and VS 2012/2013 Pro+ as-is without the DirectX SDK at all.

Read these blog posts:

DirectX SDK Samples Catalog

DirectX SDK Tools Catalog

Living without D3DX

DirectX SDKs of a certain age

And review these CodePlex projects:

DirectX Tool Kit

DirectXMesh

DirectXTex

DXUT for Direct3D 11

Effects 11

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81