DirectX header files not found (MinGW) - c++

I am using MinGW compiler with the command line and sublime text 3. While including the header files for DirectX into my C++ code, it gave errors saying they weren't found.
#include <windows.h>
#include <windowsx.h>
#include <d3d11.h>
#include <d3dx11.h>
#include <d3dx10.h>
This results in the following error:
lesson 5.cpp:4:20: fatal error: d3dx11.h: No such file or directory
#include <d3dx11.h>
If I comment out the line it gave an error for, it just gives the same error for the next line.

Related

Error in Compiling OpenGL code under Windows

I am trying to compile an OpenGL program.
This is the portion of the code with all the includes:
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glut.h>
// Usage of degrees is deprecated. Use radians for glm functions.
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "shaders.h"
The file i am trying to run is called mytest1.cpp and i also have shaders.h in the same directory.
In the same directory i have a folder called 'include' And inside two subfolders called 'GL' and 'glm' with all the files inside that are required from the program.
So i go to the directory of the mytest1.cpp and i type g++ mytest1.cpp and i get the error:
mytest1.cpp:14:21: fatal error: GL/glew.h: No such file or directory
#include <GL/glew.h>
^
compilation terminated.
Why does this happen? I also tried to place the 'GL' folder in the root directory and i got the same error

How to properly include headers and use STL vector in c++ app?

I decided to try STL and use a vector instead of a custom made growable array class. The problem is that I can't get anything to compile. If I do something like this:
#include "stdafx.h"
#include <vector>
std::vector<PITEMID_CHILD> APIDL;
I get a bunch of messages similar to this:
1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.16.27023\include\cstdint(23): error C2039: 'int_least8_t': is not a member of '`global namespace''
If I change to this:
#include <vector>
#include "stdafx.h"
std::vector<PITEMID_CHILD> APIDL;
I get this:
1>x:\win32testing\vectortest\vectortest.cpp(4): error C2039: 'vector': is not a member of 'std'
Inside of stdafx.h is this:
#pragma once
#include <windows.h>
#include "targetver.h"
// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <shlobj.h>
#include <exdisp.h>
#include <shellapi.h>
#include <shlwapi.h>
#include <atlbase.h>
#include <atlalloc.h>
#include <CommonControls.h>
// reference additional headers your program requires here
#include <CommCtrl.h>
Any idea what is going on?
From wikipedia documentation:
Visual C++ will not compile anything before the #include "stdafx.h" in the source file, unless the compile option /Yu'stdafx.h' is unchecked (by default); it assumes all code in the source up to and including that line is already compiled.
The best solution is to get rid of precompiled headers.
And for your C2039 error, it doesn't seem to be a result of line std::vector<PITEMID_CHILD> APIDL;. int_least8_t is a type defined in cstdint (stdint.h). It seems you haven't included this header file in your project.

Visual Studio doesn't find GL/glut.h

I'm using Microsoft Visual Studio Community 2017 on Windows 10 and I've been trying to install GLUT using this online guide that I found on this StackOverflow question. However, when I try to compile my code this error still shows up: fatal error C1083: Cannot open include file: 'GL\glut.h': No such file or directory. I've followed every single step line by line, but nothing seems to work. What could be causing this error?
This is how I'm importing the dependencies:
#include <iostream>
#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <GL/GL.h>
#include <GL/GLU.h>
#include <GL/glut.h>
#include <cstring>
#include "math.h"
#include <conio.h>
For this, I like to use the Nuget package manager. If you go to
Tools>NuGet Package Manager>Package Manager Console
Then, in the console type:
Install-Package nupengl.core
Your problem should be fixed.

Errors when compiling (Sublime/Visual Studio)

I am using Sublime Text 3 (build 3126) with g++ on Windows 10 x64 to compile my c++. My code so far is:
#include <stdio.h>
#include <windows.h>
#include <wincrypt.h>
#include <string>
using namespace std;
int main() {
return 0;
}
But when I compile, I get the error
wincrypt.h: No such file or directory.
I have also tried using Visual Studio 2015, but when I build it always gives me the error
Cannot open include file: 'stdio.h': No such file or directory
Any help is appreciated, thanks.

Compiling c++ with SDL2 in terminal

I have been unable to compile a basic class file to generate a window using SDL2, using both brew and compiling from the SDL site using using...
#include <SDL2/SDL.h>
at the top of the file.
Have also used...
#include <SDL/SDL.h>
#include "SDL"
among others and nearly always get this error
./src/window.cpp:1:10: fatal error: 'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>
Something should have worked and just hasn't.