0
\$\begingroup\$

I'm in the process of learning DirectX and in the examples supplied with the book I get the following error:

Error 29 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1800' in d3dApp.obj

Google didn't really come up with anything, or rather I was struggling to understand how to fix it from what I read, could someone explain what it means/how to fix it?

The line of code that is causing it is:

ID3D10Blob* compiledShader = 0;

HR(D3DX11CreateEffectFromMemory(compiledShader->GetBufferPointer(), compiledShader->GetBufferSize(),
    0, md3dDevice, &mFX));
\$\endgroup\$
1
\$\begingroup\$

You're trying to use .obj files produced with a different version of the compiler. You need to use the same older version of Visual C++ or you need to recompile whatever object files you're using. Presumably d3dApp.cpp and some others are source files provided with your book and you're using the pre-compiled versions instead of the sources.

\$\endgroup\$
6
  • \$\begingroup\$ Ah yeah, that's correct. How do I recompile the object files? The files i'm using are all source files, but I've tried all the rebuild options (which I assume you mean by recompile?). \$\endgroup\$ Nov 15 '13 at 0:28
  • \$\begingroup\$ If you've included the original .cpp files, this error is pretty odd. If you were asked to upgrade an existing project/solution file, it's possible the conversion process just gave you a borked file. You might try creating new from-scratch project files and adding the .cpp files yourself. If you need more help on that, StackOverflow is the right place. \$\endgroup\$ Nov 15 '13 at 0:36
  • \$\begingroup\$ Ah sorry my bad, it wasn't just a cpp file, an effects11.obj file is included and that's the one causing it. Is there no other way around it other than using an older version of the compiler? I'm not sure if I have the option of re-compiling it. \$\endgroup\$ Nov 15 '13 at 2:22
  • \$\begingroup\$ @user1157885: No, not really. You could download older Express versions of VS if you need the older compiler. Note that this may be one of the source files that's distributed with the DX SDK. The effects framework is distributed as source instead of a pre-built DLL in D3D11. I think you need to look at and copy some of the code in C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\Effects11. \$\endgroup\$ Nov 15 '13 at 2:29
  • \$\begingroup\$ In fact, I'm almost certain that's the solution, since D3DX11CreateEffectFromMemory is one of the functions you have to copy and build yourself now. \$\endgroup\$ Nov 15 '13 at 2:30
0
\$\begingroup\$

The warning is a protection mechanism in the compiler when linking static libraries made with one version of the VC compiler with code built by another version of the VC compiler. This only matters for some specific headers, notably STL, but can also get pulled in by some other headers in older versions of the compiler (such as stdint.h). This does not affect import libraries for DLLs, just static libraries that contain code.

I'm guessing you are using a static library of Effects 11 that was built by the book author, since we never shipped a static library of it just the source in the legacy DirectX SDK.

The solution here is really simple: Build Effects 11 yourself with your current compiler. The latest version of Effects 11 is on CodePlex.

Note that the book you are using likely has some other deprecated D3DX11 stuff as well. See this blog post for some modern replacements. Also be aware that since you are apparently using Visual Studio 2013 (the MSCVER 1800 compiler), but the book was using Visual Studio 2010 (the MSCVER 1600 compiler), the setup for projects that use legacy DirectX SDK must change since VS 2012 and VS 2013 have the Windows 8.x SDK. See MSDN and this blog post.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.