Hundreds of Errors When Including "D3DX11Effect.h" - c++

Whenever I include D3DX11Effect.h in my project, I get hundreds of errors from multiple different DirectX header files that do not give me errors when I do not include D3DX11Effect.h. These are my includes:
#include <string>
#include <dwmapi.h>
#include <iostream>
#include <Windows.h>
#include <vector>
#include <thread>
#include <chrono>
#include <string>
#include <sstream>
#include <TlHelp32.h>
#include <exception>
#include <memory>
#include <vector>
#include <D3D11.h>
#include <d3dx11.h>
#include <DXErr.h>
#include <D3DX11async.h>
#include <D3DX11Effect.h>
#include <D3Dcompiler.h>
#include <D3D11Shader.h>
#include <FW1FontWrapper.h>
#include "../Drawing/ImGUI/imgui.h"
#include "../Drawing/DirectX.h"
#include "../Drawing/imgui_dx11.h"
#include "../Drawing/ShaderFX.h"
#include "../Drawing/Renderer.h"
#include "Global.h"
I'm using Direct X 11 andWindows SDK version 10.0.16299.0. I've tried reinstalling DirectX with no luck. Here is an image of some of the errors I'm getting:
Any help is appreciated.

TL;DR: Read MSDN.
The DirectX SDK is deprecated, and the Windows 8.0 SDK, Windows 8.1 SDK, and Windows 10 SDK headers are newer than the headers that shipped in the legacy DirectX SDK. You are getting a mix of old headers and hew headers, which is why you are getting those errors.
The first thing to consider is if you need to use the legacy DirectX SDK at all. Ideally you just don't use it. This means avoiding the D3DX11 utility library which itself is also deprecated. You can find a number of open source replacements for that functionality listed in the article Living without D3DX, including the latest version of Effects for Dirct3D 11.
You can continue to use the legacy DirectX SDK mixed with modern versions of the Windows SDK, but you need to do it with some care as explained at the bottom of the MSDN page Where is the DirectX SDK?:
VC++ Directory include/lib paths must be in reverse traditional order so you get the newer headers where they conflict
You need to explicitly include d3d11.h and dxgi.h before you include d3dx11.h or you end up with the wrong version--which is exactly what happened above; you are using getting an outdated version of dxgi and/or d3dcommon.
For dxerr.h, build your own version as explained here because (a) it doesn't ship in the Windows SDK, and (b) the version that ships in the legacy DirectX SDK is not fully compatible with modern versions of Visual C++.
Note that the error buried in your image: C2440 static_cast cannot convert from const char[6] to char * in renderer.h has nothing to do with the issue above. This is due to the fact that modern C++11 rules on string literals disallow using them as non-const. You should fix the code, but you can also turn off strictstrings if you don't care about portability/conformance. In any case, take some time to read up on const correctness.
See The Zombie DirectX SDK for a complete dissection of what headers conflict, which ones are unique to the DirectX SDK, and which ones have any value for DirectX 11 games on modern versions of Windows.
You should review the various posts I've made in the past 8 years on this subject as well.

Related

Errors when including intrin.h?

I'm trying to build my project, which uses things like __cpuid and __cpuidex, so I need intrin.h. When I try to include it and build my project, I get two errors. They are:
`tagMENUBARINFO::fUnused`: type of bit field too small for number of bits
in winuser.h, and in minwindef.h I get the error
`BOOL`: redefinition; different basic types
My includes:
#include <Windows.h>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <algorithm>
#include <intrin.h>
I need all of these includes, so removing some isn't really an option.
I'm using Visual Studio 2019 as my compiler, my Windows SDK Version is 10.0, and the C++ language standard is ISO C++14 Standard.

Where is strtof() in VS2012?

I can litterally not find which library/header this function is in, I've looked at so many examples of people using this function, but there are no results...
These are all the stuff I've included:
#include "Console.h"
#include "Direct3D9.h"
#include <string>
#include <cerrno>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
But still strtof comes up as "Error namespace "std" has no member "strtof""
What I'm trying to do:
flValue = std::strtof( vszArgs.at( 1 ).c_str( ), NULL );
pConVar->Set( flValue );
Visual Studio 2012 does not implement strtof.
Link to MSDN bug report which includes a suggested workaround.
You can find it in cstdlib when using C++11. The information can easily be found here : http://www.cplusplus.com/reference/cstdlib/strtof/?kw=strtof
My guess is that you aren't compiling using c++11.
1) Include stdlib.h
#include <stdlib.h> /* strtof */
from http://www.cplusplus.com/reference/cstdlib/strtof/
If that still doesn't work...
2) Make sure your compiler is C++11 or newer
It's new as of C++11 so if you have an older compiler it won't work.
If that still doesn't work...
3) Your compiler may just not support it
Visual C++ 2012 does not have full support for the C++11 standard. See the Visual Studio bug "Missing strtof, strtold, strtoll, strtoull functions from stdlib.h".
We don't yet have those functions in the CRT. We will consider adding them to a future version of Visual C++.

OpenGL SOIL Undefined reference to glBindTexture, glTexImage2d, etc

I'm using C++ and Opengl, and I'm trying to use SOIL, but when I compile, I get undefined reference to glBindTexture, glTexImage2D, etc. However, this is only coming from SOIL.c, not my own source code. This is what the error produces:
http://pastebin.com/sKrQaBhz
My graphics card is NVIDIA GeForce GTX 680 and my drivers are fully updated. I have everything linked and I'm using premake to manage my project. I'm developing on a linux machine, however, I'm trying to cross compile it onto my windows machine, which gives this error. If I compile it on linux, it's completely fine. This is my premake4.lua file:
http://pastebin.com/T4hsbdz0
My include files is this:
#include "opengl/gl_core_3_3.hpp"
#include <GLFW/glfw3.h>
#include <SOIL/SOIL.h>
#include <glm/glm.hpp>
#include <glm/gtx/transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include "loadshader.hpp"
I'm using mingw32 to compile my code. Before I was using SOIL, everything was fine. I downloaded SOIL from their webpage at lonesock.net, which I then copied over the libSOIL.a and their include files, but it just doesn't work.
Links order matters for g++.
Try this order:
links { "SOIL", "glfw3", "opengl32", "gdi32", "glu32" }
(edit: fixed the OP answer according to the duplicated question in Premake forum: http://industriousone.com/topic/how-use-premake-compile-static-library)
Looking at SOIL homepage, they said that it must be linked staticly. So, instead of using dynamic linking ('-l' in gcc compiler), try to specify the full path of the library.
This post illustrate what I want to say: https://stackoverflow.com/a/4156190/2293156
gcc -lsome_dynamic_lib some_static_lib.a code.c

OpenGL Linking error? Unresolved external glCreateShader()

I'm working on an OpenGL program to test out shaders and trying to compile them. However, the call to glCreateShader() (and other shader calls like glDeleteShader) give the following error:
(this error is from glCreateShader())
Error 3 error LNK2001: unresolved external symbol _pglCreateShader
I'm using Visual Studio 2012 and on windows 7. Got one of the latest nvidia cards including the latest drivers so can't be my OpenGL version.
I'm using the glTools header files for all the helper functions for the OpenGL Superbible 4th edition. Not sure if there is an error in using these files?
I'll post my includes in case this could be of any help as well.
#pragma once
#include <Windows.h>
// Basic C++ includes
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
using namespace std;
// OpenGL specific and GUI includes
#include "shared/gltools.h"
#include "shared/math3d.h"
#include <SOIL.h>
And linker options:
soil.lib;opengl32.lib;gltools.lib;
Oké, the problem has been solved thanks to the answers:
I edited my glTools.h to include 'gl/glew.h' instead of "glee.h", added a ;glew32.lib option to my linker and added glewInit() before entering the main loop. I've also added the GLEW libs,dlls and includes into the appropriate folder and all the functions work like they should! :)
Grab a copy of GLEW to handle extension loading.
Doing it by hand is...annoying.
On Windows, you use WGL, and when using WGL you can't just link against the GL functions directly. All the functions you get are these; you're supposed to dynamically grab the pointer to the GL entry point you want with wglGetProcAddress (as in here) before you can use them.
Basically, OpenGL on Windows is a PITA if you do the GL entrypoint function pointer loading manually. It's much easier to use a utility library to grab the pointers for you, such as GLEW.

VC++ 10.0 express gdi+ GdiPlusPen.h header

When i include GdiPlus.h,Pen class is undefined.
But GdiPlus.h includes GdiPlusPen.h
...
#include "GdiplusImageAttributes.h"
#include "GdiplusMatrix.h"
#include "GdiplusBrush.h"
#include "GdiplusPen.h"
#include "GdiplusStringFormat.h"
#include "GdiplusPath.h"
...
When i include GdiPlusPen.h myself, it works. Can i use it safely?
Question: is this because of my VC++ being express install?
8 days left until activation prompt :(
Anyone having same problem?
Windows XP sp-3, pentium-m centrino.
No, #including GdiplusPen.h directly isn't correct. The gdiplus classes live in a namespace named "Gdiplus". Either use that namespace explicitly (like Gdiplus::Pen) or make it look like this in your .cpp file:
#include <gdiplus.h>
using namespace Gdiplus;