When I compile main.cpp I get an undefined reference to a class::function() and I cant seem to find what the issue is at all, I had all my code in one cpp file and it worked fine but I separated the functionality into a new header file with a corresponding cpp file that includes the header file
When I create an object (MainWindow m;) and compile that I dont get errors, but when I add m.init() thats when I get the undedfined reference to MainWindow::init();
mainWindow.h:
#pragma once
#include <gtkmm.h>
#include <string>
#include <fstream>
class MainWindow {
    protected:
        Gtk::Window *main_window;
        Gtk::Button *text_button;
        Gtk::TextView *text_view;
        Gtk::Dialog *file_dialog;
        Gtk::Entry *file_entry;
        Gtk::Button *file_button;
        std::string file;
    public:
        void init();
        void open_dialog();
        void get_entry();
};
mainWindow.cpp:
#include "mainWindow.h"
void MainWindow::get_entry() {
    file = file_entry->get_text();
    file_dialog->close();
}
void MainWindow::open_dialog() {
    std::string newText, line, file;
    file_dialog->run();
    file_button->signal_clicked().connect(sigc::ptr_fun(&get_entry));
    std::ifstream textFile(file);
    while (getline(textFile, line)) {
        newText += line;
        newText += " ";
    } 
    text_view->get_buffer()->set_text(newText);
}
void MainWindow::init() {
    Gtk::Main app();
    auto builder = Gtk::Builder::create_from_file("test.glade");
    builder->get_widget("main_window", main_window);
    builder->get_widget("text_button", text_button);
    builder->get_widget("text_view", text_view);
    builder->get_widget("file_dialog", file_dialog);
    builder->get_widget("file_entry", file_entry);
    builder->get_widget("file_button", file_button);
    text_button->signal_clicked().connect(sigc::ptr_fun(&open_dialog));
    Gtk::Main::run(*main_window);
}
main.cpp:
#include "mainWindow.h"
#include <iostream>
int main() {
    MainWindow m;
    m.init();
}
