# No such file GLFW/glfw3.h

**URL:** <https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153>\
**Category:** support\
**Created:** [September 18, 2022, 10:45am UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153 "2022-09-18T10:45:21Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnnoyingB](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/annoyingb/32/669_2.png) [@AnnoyingB](https://discourse.glfw.org/u/AnnoyingB)\
**Post date:** [September 18, 2022, 10:45am UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/1 "2022-09-18T10:45:21Z")

</div>

Directory:

```auto
Solution\
    Project\
        Dependencies\
            GLFW\
                glfw3.h
                glfw3native.h
            lib\
                glfw3.lib
                glfw3_mt.lib

```

I included glfw3.lib and glfw3\_mt.lib and my directory is in dependencies  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/621ea4c029f29c51103b1bb73ee6e5828befb250.png)

---

<div class="post-metadata">

**Author:** ![AnnoyingB](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/annoyingb/32/669_2.png) [@AnnoyingB](https://discourse.glfw.org/u/AnnoyingB)\
**Post date:** [September 18, 2022, 11:58am UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/2 "2022-09-18T11:58:46Z")

</div>

I fixed the error by setting another project to require the project but now I just have unresolved external symbols for Vulkan

```auto
unresolved external symbol 'private: static struct VkInstance_T*'
unresolved external symbol 'private: static struct VkDebugUtilsMessengerEXT_T*'

```

---

<div class="post-metadata">

**Author:** ![AnnoyingB](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/annoyingb/32/669_2.png) [@AnnoyingB](https://discourse.glfw.org/u/AnnoyingB)\
**Post date:** [September 18, 2022, 2:11pm UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/3 "2022-09-18T14:11:42Z")

</div>

I have gotten the error again 😑

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [September 18, 2022, 4:30pm UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/4 "2022-09-18T16:30:01Z")

</div>

Welcome to the GLFW forum.

It looks like you are using Visual Studio. If you open the `C/C++>General` properties page for your project and then click on the arrow to the right of the `Additional Include Directories` you will open up a dialogue which shows the evaluated values of the include directories. Check that the `Dependencies` directory is correctly listed there (i.e that `$(ProjectDir)` evaluates to `Solution\Project`).

For Vulkan you need to link to the Vulkan libraries. You might want to follow a tutorial for Visual Studio such as the one:

> **[Development environment - Vulkan Tutorial](https://vulkan-tutorial.com/Development_environment)**
>
> A tutorial that teaches you everything it takes to render 3D graphics with the Vulkan API. It covers everything from Windows/Linux setup to rendering and debugging.

---

<div class="post-metadata">

**Author:** ![AnnoyingB](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/annoyingb/32/669_2.png) [@AnnoyingB](https://discourse.glfw.org/u/AnnoyingB)\
**Post date:** [September 18, 2022, 4:31pm UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/5 "2022-09-18T16:31:33Z")

</div>

It is pointing to dependencies

---

<div class="post-metadata">

**Author:** ![AnnoyingB](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/annoyingb/32/669_2.png) [@AnnoyingB](https://discourse.glfw.org/u/AnnoyingB)\
**Post date:** [September 18, 2022, 4:32pm UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/6 "2022-09-18T16:32:39Z")

</div>

no file can use glfw3.h

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [September 18, 2022, 4:59pm UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/7 "2022-09-18T16:59:35Z")

</div>

I would try the following project:

> **[GitHub - juliettef/GLFW-CMake-starter: Use CMake to create a project with GLFW...](https://github.com/juliettef/GLFW-CMake-starter)**
>
> Use CMake to create a project with GLFW - Multi-platform Windows, Linux and MacOS. - GitHub - juliettef/GLFW-CMake-starter: Use CMake to create a project with GLFW - Multi-platform Windows, Linux a...

This uses CMake and OpenGL, but if you follow the instructions it will create a working Visual Studio project. You can then use that to help you figure out why your own project isn’t working.

---

<div class="post-metadata">

**Author:** ![AnnoyingB](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/annoyingb/32/669_2.png) [@AnnoyingB](https://discourse.glfw.org/u/AnnoyingB)\
**Post date:** [September 18, 2022, 5:13pm UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/8 "2022-09-18T17:13:29Z")

</div>

I fixed it by including it in the other project that is using it but I am getting:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/9f0eabf262a8b4d671e48ee99656b09390fa2b3d.png)

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [September 18, 2022, 5:53pm UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/9 "2022-09-18T17:53:55Z")

</div>

You need to link to the Vulkan library, the link to the Vulkan tutorial I posted has an example of how to do that.

---

<div class="post-metadata">

**Author:** ![AnnoyingB](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/annoyingb/32/669_2.png) [@AnnoyingB](https://discourse.glfw.org/u/AnnoyingB)\
**Post date:** [September 18, 2022, 5:58pm UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/10 "2022-09-18T17:58:41Z")

</div>

i linked vulkan-1.lib

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [September 18, 2022, 6:56pm UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/11 "2022-09-18T18:56:28Z")

</div>

Ah, apologies I didn’t read the image properly since it was so small on my monitor. You have multiple definitions of the Vulkan `struct VkInstance_T* initVulkan::instance` etc. I can’t see the full error message (please paste full text not images of part of the compilation & link output if possible) so it’s difficult to tell why.

One common reason this can happen is you have both declared and defined a function in a header file, but not declared it as inline. For example if you have:

```auto
// in a MyClass.h
struct MyClass
{
    void MyFunc();
};

void MyClass::MyFunc() { return; } // This will cause multiple definition errors.

```

This can be fixed as:

```auto
// in a MyClass.h
struct MyClass
{
    inline void MyFunc();
};

inline void MyClass::MyFunc() { return; } // This will cause multiple definition errors.

```

Please do note it’s _really_ hard to help when I don’t have the code, project, full error messages etc.

---

<div class="post-metadata">

**Author:** ![AnnoyingB](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/annoyingb/32/669_2.png) [@AnnoyingB](https://discourse.glfw.org/u/AnnoyingB)\
**Post date:** [September 18, 2022, 7:00pm UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/12 "2022-09-18T19:00:40Z")

</div>

I dont have that problem. Here is my code:

```auto
// InitVulkan.h

#pragma once

#define GLFW_INCLUDE_VULKAN

#include "../../Errors.h"
#include "GLFW/glfw3.h"
#include <iostream>
#include <vector>
#include <map>
#include <optional>
#include <string>

namespace InitVulkan
{
	VkInstance instance;
	VkDebugUtilsMessengerEXT debugMessenger;

	ANDROERRORS CreateInstance();
	ANDROERRORS CreateDebugger();

	ANDROERRORS Init();
	ANDROERRORS Cleanup();
};

```

```auto
// InitVulkan.cpp
#include "InitVulkan.h"

const std::vector<const char*> validationLayers = {
	"VK_LAYER_KHRONOS_validation"
};

#ifdef NDEBUG
const bool enableValidationLayers = false;
#else
const bool enableValidationLayers = true;
#endif

static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
	VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
	VkDebugUtilsMessageTypeFlagsEXT messageType,
	const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
	void* pUserData) {

	std::cerr << "validation layer: " << pCallbackData->pMessage << std::endl;

	return VK_FALSE;
}

VkResult CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger) {
	auto func = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT");
	if (func != nullptr) {
		return func(instance, pCreateInfo, pAllocator, pDebugMessenger);
	}
	else {
		return VK_ERROR_EXTENSION_NOT_PRESENT;
	}
}

void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator) {
	auto func = (PFN_vkDestroyDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT");
	if (func != nullptr) {
		func(instance, debugMessenger, pAllocator);
	}
}

void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo) {
	createInfo = {};
	createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
	createInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
	createInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
	createInfo.pfnUserCallback = debugCallback;
}

bool checkValidationLayerSupport() {
	uint32_t layerCount;
	vkEnumerateInstanceLayerProperties(&layerCount, nullptr);

	std::vector<VkLayerProperties> availableLayers(layerCount);
	vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());

	return false;
}

ANDROERRORS InitVulkan::CreateDebugger()
{
	if (!enableValidationLayers) return ANDROERRORS::NONE;

	VkDebugUtilsMessengerCreateInfoEXT createInfo;
	populateDebugMessengerCreateInfo(createInfo);

	if (CreateDebugUtilsMessengerEXT(instance, &createInfo, nullptr, &debugMessenger) != VK_SUCCESS) {
		return ANDROERRORS::VULKAN_DEBUGGER_CREATION_FAILED;
	}

	return ANDROERRORS::NONE;
}

ANDROERRORS InitVulkan::Init() {
	ANDROERRORS error = CreateInstance();
	if (error != ANDROERRORS::NONE)
		return error;
	error = CreateDebugger();
	if (error != ANDROERRORS::NONE)
		return error;
}

ANDROERRORS InitVulkan::CreateInstance() {
	if (enableValidationLayers && !checkValidationLayerSupport()) {
		return ANDROERRORS::VULKAN_VALIDATION_REQUESTED_NONE_FOUND;
	}

	/*
	VkStructureType sType;
	const void* pNext;
	const char* pApplicationName;
	uint32_t applicationVersion;
	const char* pEngineName;
	uint32_t engineVersion;
	uint32_t apiVersion;
	*/

	VkApplicationInfo appInfo{};
	appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
	appInfo.pApplicationName = "Andromeda";
	appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
	appInfo.pEngineName = "Vulkan";
	appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
	appInfo.apiVersion = VK_API_VERSION_1_0;

	VkInstanceCreateInfo createInfo{};
	createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
	createInfo.pApplicationInfo = &appInfo;

	uint32_t glfwExtensionCount = 0;
	const char** glfwExtensions;

	glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);

	createInfo.enabledExtensionCount = glfwExtensionCount;
	createInfo.ppEnabledExtensionNames = glfwExtensions;

	VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo{};
	if (enableValidationLayers) {
		createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
		createInfo.ppEnabledLayerNames = validationLayers.data();

		populateDebugMessengerCreateInfo(debugCreateInfo);
		createInfo.pNext = (VkDebugUtilsMessengerCreateInfoEXT*)&debugCreateInfo;
	}
	else {
		createInfo.enabledLayerCount = 0;

		createInfo.pNext = nullptr;
	}

	std::vector<const char*> requiredExtensions;

	for (uint32_t i = 0; i < glfwExtensionCount; i++) {
		requiredExtensions.emplace_back(glfwExtensions[i]);
	}

	requiredExtensions.emplace_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);

	createInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;

	createInfo.enabledExtensionCount = (uint32_t)requiredExtensions.size();
	createInfo.ppEnabledExtensionNames = requiredExtensions.data();

	uint32_t extensionCount = 0;
	vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);

	std::vector<VkExtensionProperties> extensions(extensionCount);

	vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, extensions.data());

	if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) {
		return ANDROERRORS::VULKAN_INIT_FAILED;
	}

	return ANDROERRORS::NONE;
}

ANDROERRORS InitVulkan::Cleanup() {
	if (enableValidationLayers) {
		DestroyDebugUtilsMessengerEXT(instance, debugMessenger, nullptr);
	}

	vkDestroyInstance(instance, nullptr);

	return ANDROERRORS::NONE;
}

```

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [September 19, 2022, 10:00am UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/13 "2022-09-19T10:00:29Z")

</div>

You have two variables defined in the header file:

```auto
namespace InitVulkan
{
	VkInstance instance;
	VkDebugUtilsMessengerEXT debugMessenger;

```

This will cause a multiple definition error in the linker by breaking the **One Definition Rule (ODR)** if this header is included by more than one source file, see:  
[https://en.cppreference.com/w/cpp/language/definition](https://en.cppreference.com/w/cpp/language/definition)

To fix this you could pass the variables as part of the function parameters and return values, or make the variables static members of a struct (and define them in the C++ file).

So you could do:

```auto
    ANDROERRORS Init( VkInstance& instance, VkDebugUtilsMessengerEXT& debugMessenger);

```

and then define these variables in your main function and pass them to the Init function etc.

---

<div class="post-metadata">

**Author:** ![AnnoyingB](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/annoyingb/32/669_2.png) [@AnnoyingB](https://discourse.glfw.org/u/AnnoyingB)\
**Post date:** [September 19, 2022, 10:59am UTC](https://discourse.glfw.org/t/no-such-file-glfw-glfw3-h/2153/14 "2022-09-19T10:59:06Z")

</div>

thanks it works now!
