Here is the complete error:
Undefined symbols for architecture arm64:
"ug::UgWindow::UgWindow(int, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
_main in main.cpp.o
"ug::UgWindow::~UgWindow()", referenced from:
_main in main.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [untitled-game] Error 1
make[1]: *** [CMakeFiles/untitled-game.dir/all] Error 2
make: *** [all] Error 2
I am using cmake to build my files, i have created a UgWindow hpp file and cpp file to define its functionality here is the hpp file and cpp file.
HPP
#pragma once
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <string>
namespace ug {
class UgWindow{
public:
UgWindow(int w, int h, std::string name);
~UgWindow();
bool shouldClose(){ return glfwWindowShouldClose(window); }
private:
void initWindow();
const int width;
const int height;
std::string windowName;
GLFWwindow *window;
};
}
here is the cpp file:
#include "ug_window.hpp"
namespace ug {
UgWindow::UgWindow(int w, int h, std::string name): width{w}, height{h}, windowName{name} {
initWindow();
}
UgWindow::~UgWindow() {
glfwDestroyWindow(window);
glfwTerminate();
}
void UgWindow::initWindow() {
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
window = glfwCreateWindow(width, height, windowName.c_str(), nullptr, nullptr);
}
}
I am trying to use vulkan with glfw and glm, im a noob with c++ and have absolutely no idea how to fix this or what the problem is.
Also this is my cmake file:
project(untitled-game)
cmake_minimum_required(VERSION 3.22.4)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++17 " )
add_executable(${PROJECT_NAME} main.cpp)
find_package(Vulkan REQUIRED)
find_package(glfw3 3.3 REQUIRED)
if (VULKAN_FOUND)
message(STATUS "Found Vulkan, Including and Linking now")
include_directories(${Vulkan_INCLUDE_DIRS})
target_link_libraries (${PROJECT_NAME} ${Vulkan_LIBRARIES} glfw)
endif (VULKAN_FOUND)