Configure Clion to work with GLFW

Hello.

I´m trying to use GLFW witth Clion (the Jetbrains IDE), i configured the CMakeLists.txt getting help from other project, but compiling this project y have some troubles.

this is my output console error: https://gyazo.com/825012df43ea0b904afa324cc51d17bc

this is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.6)
project(TestGLFW)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lmingw32")
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")

include_directories(${PROJECT_SOURCE_DIR}/include)
link_directories(${PROJECT_SOURCE_DIR}/lib)

set(SOURCE_FILES main.cpp)
add_executable(TestGLFW ${SOURCE_FILES})

target_link_libraries(TestGLFW mingw32 glfw3)

And this is my test source:

#include <GLFW/glfw3.h>

int main(void){
    GLFWwindow* window;
    if (!glfwInit())
        return -1;

    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window){
        glfwTerminate();
        return -1;
    }

    glfwMakeContextCurrent(window);

    while (!glfwWindowShouldClose(window)){
        glClear(GL_COLOR_BUFFER_BIT);
        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}

Help!!

I’m not an expert with mingw32, but it looks like it expects a winMain function rather than a main function.

See this tutorial for an example.

You should be able to simply replace int main(void) with:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

It is possible to use main() with windows by setting the entry point to be that function, but I do not know how to do that with mingw32.