Why am I getting an undedined reference to this function?
I have three files: window.h: #include <SDL2/SDL.h> #include <SDL2/glew.h> class Window { public: Window() {} ~Window() {} void run(); void initSDL(); private: SDL_Window* _window; int _width = 1024; int _height = 678; }; window.cpp: #include "window.h" int main() { void Window::Window() { _window = nullptr; } void Window::~Window() { } void Window::run() { initSDL(); } void Window::initSDL() { SDL_Init(SDL_INIT_EVERYTHING); _window = SDL_CreateWindow("Neptune's Limit", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, _width, _height, SDL_WINDOW_OPENGL); } } main.cpp: #include <iostream> #include "window.h" #include "window.cpp" int main(int argc, char* argv[]) { Window window; window.run(); std::cout << "Enter any character to continue" << std::endl; char a; std::cin >> a; return 0; } When I run it, nevermind all the confusing SDL functions, I get an undefined reference to Window::run(). Why?