"Cannot open include file: 'vulkan/vulkan.h': No such file or directory" when static library is build as part of a solution in VS 2019

Viewed 3461

I'm currently experimenting with the vulkan API and have trouble building my solution with VS 2019. The setup is as follows:
I have a multi-project solution with 2 projects: A static library called *Engine* and an application called *Game*.
External libs: vulkan, GLFW and GLM.
Dependencies are configured almost the same as described in [Vulkan Tutorial][1] with slight adjustments for the static lib, exact setup can be found at the end of this post on screenshots.

My problem is this:
When I build the Engine by itself, everything is fine and no errors occur.
If I build the whole solution and only #include "Engine.h" or "util.h" in "Game.cpp" (source file with main method in Game) then it works as well and if I execute it a window opens and the debug output is correct as well.
But if I #include "Configuration.h" in "Game.cpp" the error as stated in the title occurs. The only difference I notice between the files is that "Engine.h" and "util.h" do not include any vulkan code but rather their source file counterparts "Engine.cpp" and "util.cpp" do, while "Configuration.h" contains #include "vulkan/vulkan.h".

Does anyone have any idea what might be the problem and how to fix it?


Code

Engine.h

#pragma once
namespace re 
{
  class REngine
  {
  public:
    void init();
  };
}

Engine.cpp

#include "Engine.h"

#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>

#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/vec4.hpp>
#include <glm/mat4x4.hpp>

//std
#include <iostream>
namespace re {
    void REngine::init()
    {
#ifdef _DEBUG
        std::cout << "Realms Engine begin initializing." << std::endl;
#endif // _DEBUG
        glfwInit();

        glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
        GLFWwindow* window = glfwCreateWindow(800, 600, "Vulkan window", nullptr, nullptr);

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

        std::cout << extensionCount << " extensions supported\n";

        glm::mat4 matrix;
        glm::vec4 vec;
        auto test = matrix * vec;

        while (!glfwWindowShouldClose(window)) {
            glfwPollEvents();
        }

        glfwDestroyWindow(window);

        glfwTerminate();
    }
}

Configuration.h

#pragma once

#include "vulkan/vulkan.h"

namespace re {
    class RConfiguration
    {
    private:
        VkApplicationInfo m_appInfo;
        const int m_height;
        const int m_width;
        
    public:
        RConfiguration(
            const char* name,
            int height, int width, 
            int major, int minor, int patch
        );

        const int get_width() { return m_width; }
        const int get_height() { return m_height; }
        VkApplicationInfo get_app_info() { return m_appInfo; }
    };

}

Configuration.cpp

#include "Configuration.h"

namespace re {
    RConfiguration::RConfiguration(const char* name, int height, int width, int major, int minor, int patch): m_height(height), m_width(width)
    {
        m_appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
        m_appInfo.pApplicationName = name;
        m_appInfo.applicationVersion = VK_MAKE_VERSION(major, minor, patch);
        m_appInfo.pEngineName = "Realms Engine";
        m_appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
        m_appInfo.apiVersion = VK_API_VERSION_1_2;
    }
}

Game.cpp

#include <iostream>

#include "Engine.h"
#include "util.h"
#include "Configuration.h"

int main()
{
    std::cout << "Hello World!\n";
    re::REngine engine;
    auto version = re::util::make_version(1, 2, 1);
    std::cout << version << std::endl;
    engine.init();
}


re::RConfiguration make_config() {
    return re::RConfiguration(
        "Realms in the Sky",
        600,
        800,
        1, 0, 0
    );
}

Project Setup

Engine
Engine Additional Include Directories Engine Additional Library Directories Engine Additional Dependencies Engine Property Pages

Game
Game Property Pages Game References

0 Answers
Related