I am working on learning C++ development and I wanted to have a file that can be used to create a window. When I run my build, it completes without an error and both CLion and Copilot have been unable to find any sort of errors. But when I run my main.cpp file, it says that my Window.cpp is unable to find the GLFW/glfw3.h file.
My CMakeLists.txt file looks like this below:
cmake_minimum_required(VERSION 3.27)
project(Mako)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/dependencies/glfw-3.4")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/dependencies/glfw-3.4/include/GLFW")
find_package(OpenGL REQUIRED)
set(CMAKE_CXX_STANDARD 17)
set(SOURCE_FILES main.cpp
Window.cpp
Window.h
)
add_library(Mako ${SOURCE_FILES})
target_link_libraries(Mako glfw ${GLFW_LIBRARIES})
My code isn't anything spectacular honestly, I have a Window.cpp and Window.h file as well as a main.cpp which I'm using to test. I'm curious if I need to include the GLFW/glfw3.h file in my Window.h file but I'm not sure how to map that correctly as I am just starting to learn C++ and it's entirely reasonable I'm just being an idiot and not creating the files correctly and don't need the Window.h file and it's just causing main.cpp to become confused.
Window.cpp
#include "Window.h"
#include <GLFW/glfw3.h>
#include <cstdio>
namespace graphics
{
Window *Window::getInstance() { ... }
void Window::init_window() { ... }
}
Window.h
#ifndef MAKO_WINDOW_H
#define MAKO_WINDOW_H
namespace graphics
{
class Window
{
Window* window;
public:
static Window* getInstance();
static void init_window();
void error_callback(int error, const char* description);
};
}
#endif //MAKO_WINDOW_H
main.cpp
#include "Window.cpp"
using namespace graphics;
int main() {
graphics::Window::init_window();
return 0;
}
I've tried including the GLFW/glfw3.h file in my Window.h file but ran into an issue with it not being able to find the library but the Window.cpp file is. I would expect to be able to create an instance of the Window class in main.cpp.