I'm fairly new to Gtk programming. I'm using the Gtkmm library to write a simple GUI for my application.
The GUI is part of a larger application, which actually compiles to two separate executables, however I don't believe this is relevant since this question only concerns one of the two executables.
Anyway, I have the following code in client.cpp:
#include "client.hpp"
int main() {
auto builder = Gtk::Builder::create();
}
And in client.hpp I'm simply including iostream, glibmm.h, and various gtkmm widget headers, as well as gtkmm/builder.h.
My makefile is a mess, but here it is:
CXXFLAGS= -std=c++14 -g
LDFLAGS=-lgmp -pthread $(shell pkg-config -libs gtkmm-3.0)
SERVER_EXE=server
CLIENT_EXE=client
CXX=g++
DIST_DIR=.
BUILD_DIR=./build
SERVER_CXXFLAGS=
CLIENT_CXXFLAGS=$(shell pkg-config --cflags gtkmm-3.0)
INCLUDE_DIRS=./include
INCLUDE_PARAMS=$(foreach d, $(INCLUDE_DIRS), -I$d)
SERVER_OBJECTS=rsa.o server_entry.o server.o
SERVER_OBJECT_PATHS=$(foreach o, $(SERVER_OBJECTS), $(BUILD_DIR)/$o)
CLIENT_OBJECTS=resources.o client.o
CLIENT_OBJECT_PATHS=$(foreach o, $(CLIENT_OBJECTS), $(BUILD_DIR)/$o)
all: $(SERVER_OBJECT_PATHS) $(CLIENT_OBJECT_PATHS)
mkdir -p $(DIST_DIR)
$(CXX) $(CLIENT_OBJECT_PATHS) -o $(DIST_DIR)/$(CLIENT_EXE) $(LDFLAGS)
$(CXX) $(SERVER_OBJECT_PATHS) -o $(DIST_DIR)/$(SERVER_EXE) $(LDFLAGS)
clean:
rm -rf $(BUILD_DIR)
rm $(DIST_DIR)/$(CLIENT_EXE) $(DIST_DIR)/$(SERVER_EXE)
$(BUILD_DIR)/%.o: %.cpp
mkdir -p $(BUILD_DIR)
$(CXX) -c $< $(INCLUDE_PARAMS) -o $@ $(CXXFLAGS) $(SERVER_CXXFLAGS) $(CLIENT_CXXFLAGS)
resources.cpp:
glib-compile-resources --target=resources.cpp --generate-source windows.gresource.xml
I realise that's a lot to take in, since it's actually building two executables, but for this question you can safely only regard things which are related to the client program.
The rule right at the bottom is used to turn the glade file I made into a c++ file which can be linked to my client.cpp file.
Anyway, when I run my program I get the following output:
(process:16593): GLib-GObject-CRITICAL **: 23:15:27.886: g_object_set_qdata_full: assertion 'quark > 0' failed
I'm at a complete loss as to what this error message could mean. Since I'm not very experienced with this library, I'm not sure quite what to make of it. I also tried adding a line after my code to load the builder widgets from a resource, but that created even more critical errors and segfaulted. I'm hoping if I can fix this first error, everything else will fall into place. Any thoughts? Thanks!
UPDATE 1: When I change the source of client.cpp to the source code supplied here, it works perfectly! So that's odd..