The code compiles without any errors. At runtime the code results in a segmentation fault. Using gdb I managed to find out that the line the application crashes on it the call to gtk_dialog_run. Does anyone know why this could be happening?
#include <GLFW/glfw3.h>
#include "config.h" //Configured constants
#include "platform.h" //Platform specific functions
//Further includes
int main(int argc, char* argv[])
{
Platform::Initialize(argc, argv); //Initialize platform
glfwInit(); //Initialize GLFW
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
GLFWwindow* window = glfwCreateWindow(Config::WINDOWWIDTH,
Config::WINDOWHEIGHT, "Main window", nullptr, nullptr); //Create GLFW window
if(window == nullptr)
{
Platform::ShowMessage("Failed to create the main window"); //Show message on failure
glfwTerminate();
return 1;
}
//Further code
return 0;
}
Could it have something to do with the fact that I initialize GLFW after I initialize GTK? Maybe it uses GTK internally and it could be initialized twice?
EDIT:
It appears the call to glfwInit was the problem. Calling glfwInit after calling gtk_init seems to cause some parts of GTK3 to cause segmentation faults. The problem was solves by calling glfwInit before Platform::Initialize.
Thank you for your help. I thought GTK code was the problem.