Search code examples
c++compiler-errorsgtkmm

GTKmm Hello World Compile error


so i am making a basic hello world app in c++ here is the code

View.h

#ifndef VIEW_H
#define VIEW_H

#include <gtkmm/button.h>
#include <gtkmm/window.h>

class View : public Gtk::Window
{
    public:
        View();
        virtual ~View();

protected:
    //signal handlers
    void on_button_clicked();


    //Member Widgets
    Gtk::Button m_button;
}

#endif

View.cpp

#include "helloWorld.h"
#include <iostream>

View::View(): m_buton("Hello World")
{
set_border_width(10);

m_button.signal_clicked().connect(sigc::mem_fun(*this, &View::on_button_clicked));

add (m_button);

m_button.show();


}

View::~View()
{
}


void View::on_button_clicked()
{
        std::cout << "Hello World" << std::endl;
}

Main.cpp

#include "View.h"
#include <gtkmm/main.h>

int main (int argc, char *argv[])
{
Gtk::Main kit(argc, argv);

View helloWorld;

Gtk::Main::run(helloWorld);

return 0;
}

and finally my makefile

Out: Main.o View.o
    g++ -o Out Main.o View.o `pkg-config gtkmm-3.0 --cflags --libs`

Main.o: Main.cpp View.h
    g++ -c Main.cpp `pkg-config gtkmm-3.0 --cflags --libs`

View.o: View.cpp View.h
    g++ -c View.cpp `pkg-config gtkmm-3.0 --cflags --libs`

I have Gtkmm 3.0 installed, and have looked around extensivly to find an answer, my error is

g++ -c Main.cpp `pkg-config gtkmm-3.0 --cflags --libs`
In file included from /usr/include/glibmm-2.4/glibmm/optioncontext.h:27:0,
                 from /usr/include/gtkmm-3.0/gtkmm/main.h:36,
                 from Main.cpp:2:
/usr/include/glibmm-2.4/glibmm/optionentry.h:30:8: error: expected unqualified-id before string constant
make: *** [Main.o] Error 1

how do i Fix this? it looks to me somewhere in my main method triggers an issue with the gtkmm code? i'm confused my code is almost exactly what i found online for how to do this i merely changed the name of the HelloWorld Class to View


Solution

  • You forgot the ; at the end of your class definition.