简体   繁体   中英

How do I set up an OpenGL/C++ project with GLM?

I'm using Visual Studio 2013 for an OpenGL/C++ project and now I need to work with the GLM library .

I've downloaded the library and extracted it in my project folder. Then I set [addictional directories] from the properties of the project but it keeps giving me:

fatal error LNK1104: cannot open file 'glm.lib'

But there is not a glm.lib in the .zip on the website. Here are the "includes" in my main:

#include <GL\glew.h>
#include <GL\freeglut.h>
#include <iostream>
#include <cstdlib>
#include "imageLoader.h
#include "..\glm-0.3.2\glm\glm.h"

The website you linked only provides sources for the library. You will have to build it yourself to use it.

The source provides a Makefile.am to build the library with autotools but since you are using Visual Studio, it might be a little tricky to build it this way. On the other hand, this library is really small - only ten source files or so. It will probably be easier for you to just add these sources to you current VS project and build them with the default VSC++ compilation tools.

Also, there is a more common C++ library related to Opengl with the same name. The one you are trying to use seems to load wavefront obj files. The GLM I know is a helper 3D math library with GLSL syntax ( GLM ).

Regarding Visual Studio 2017 I suggest following:

  1. I suppose you have at least one toolkit, such as GLFW, freeGLUT, SDL, in folder C:\\OpenGL\\ and it is set up in an empty project.
  2. Go to https://glm.g-truc.net/0.9.9/index.html and download glm .
  3. Drag it (or copy and paste) from the window is downloaded into folder C:\\OpenGL. Now in folder OpenGL you have glm and at least one toolkit.
  4. Go to VS > Solution Explorer > right click the project's name > click Properties > Open the C/C++ drop-down menu > General > Additional Include Directories > Click the down arrow at the right of the field > Edit... .
  5. In Additional Include Directories window, click the first icon, copy C:\\OpenGL\\glm and paste in text box.
  6. Click [OK] in Additional Include Directories window.
  7. In the Linker drop-down menu, click Input . Click the Additional Dependencies entry and then the down arrow at the right of the field. Select Edit in the drop-down menu. Copy opengl32.lib and paste on the top-most text box in Additional Dependencies window. Click [OK] in Additional Dependencies window.
  8. Click [Apply] and [OK] in the Project Property Pages window.

That's all. Regards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM