How to set up the GLM library in visual studio 2012

How to set up a GLM library in visual studio 2012?

First I tried to extract the lmar glm directory into the VS 2012 project directory (the directory containing the glm library is called glm-0.9.4.4). then I tried to add glm-0.9.4.4 in

PROJECT → properties → VC ++ Directories → Include Directories

and then when I tried to use include #include <glm/glm.hpp> in my code, I got the following error:

Fatal error C1083: Cannot open include file: 'glm / glm.hpp': No such file or directory

How to properly configure the GLM library to work in my code?

+6
source share
3 answers

I managed to solve the problem. To add the GLM library to the inclusion path, I followed these steps:

  • the glm code directory was extracted to the directory of my project (the name of the directory in the archive downloaded from the Internet is glm-0.9.4.4). for example, if the project is located in C:\projects\myProject , then the glm code is extracted to this path ( C:\projects\myProject ).
  • than I added the full path C:\projects\myProject\glm-0.9.4.4 directory:

    => right-click on the project in the solution viewer => from the drop-down menu, select properties => C \ C ++ => General => Additional inclusion directories.

  • add C:\projects\myProject\glm-0.9.4.4 in the edit field for Include additional directories.
another option, if you do not want to use the full path for the glm library (or any other library that you want to include in the project as a whole), use the path .\glm-0.9.4.4 instead of the full path (this will only work if you extracted the glm library into the project directory!)
+6
source

GLM is just a header-only library, so you just need to include it in your project.

  • Have you actually put the GLM folder in your include path? Folder "glm-0.9.4.4" does not match "glm". Basically, make sure that the path you are trying to include is actually aligned.

  • If you include something in a local (project) directory, use quotation marks instead of angle brackets to include something. #include "glm/glm.hpp" . However, if you told VC to look in the directory where you put GLM, the brackets should work. As a rule, brackets look in your inclusion path, and quotes look at your local path. See this question for a better explanation.

By default, the default path should look something like C:/.../Microsoft Visual Studio 12/VC/include . You can drop it there so that it can be available for all your projects if you do not want to rewrite it in every new project that you do. If you do not want to do this, find the project directory and put the "glm" folder where all your header files are located, and #include with quotes instead of brackets.

Have you tried to track this yourself? Find where stdio.h lives, or where the folder named "include" is located.

+2
source

You can also simply import the entire glm folder into your project, and then use the quote to include the glm.hpp file. He worked with me in the past, without worrying that the title includes directories, etc.

+1
source

Source: https://habr.com/ru/post/950455/


All Articles