简体   繁体   中英

Cannot access GLFW/glfw3.h in Visual Studio 2019

I am trying to develop a game using GLFW and C++, but to do this I need to add add a new "Include Directory", how would I go about this?

So far, I have tried to add it to "Configuration Properties/VC++ Directories/Include Directories" and to "C\\C++/General/Additional Include Directories" and both have been unsuccessful.

In the Project File, I have a libraries folder, and inside it are a folder called "GLFW", and a file called "glfw3.lib". Inside the "GLFW" folder, there are two files called "glfw3.h" and "glfw3native.h". I am unsure what else to post in this section so apologies on that part.

I expect to be able to do the code "#include " but it comes up with an error saying that it cannot open the source file.

I appreciate any help you can give!

You need to make sure that you add the configuration properties to the correct build target and platform for your code.

If you only add these properties to the "Debug" Build Target and then try to compile in "Release" (or vise-versa) then the compiler won't be able to find your libraries.

You should manually change these properties for each Build Target you intend to build for, and for each Platform you intend to build for. Often (especially for newer programmers), it's best if you just stick with one of each (I recommend Debug for build target and x64 for Platform), so that you don't have to perform this step repeatedly.

Alternatively, if there's no difference in your libraries between debug and release (which commonly happens if you don't build the libraries yourself and just use whatever the vendor provided) you can choose, when setting your configuration, to affect ALL build targets; although this probably won't work for ALL platforms (since Win32 code can't be linked with x64 code). So you'll still need to specifically choose the correct platform for your code.

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