Skip to content

C:\...\Temp\ccX1BkzX.o: in function `main': C:\...\main.cpp:39: first defined here #8747

@GustavoRamos112

Description

@GustavoRamos112

Version/Branch of Dear ImGui:

Version 1.92, Branch: master (master/docking/etc.)

Back-ends:

imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp

Compiler, OS:

Windows 10 + MinGW + MSYS2

Full config/build information:

Project:
│ glfw3.dll
│ imconfig.h
│ imgui.cpp
│ imgui.h
│ imgui_demo.cpp
│ imgui_draw.cpp
│ imgui_impl_glfw.cpp
│ imgui_impl_glfw.h
│ imgui_impl_opengl3.cpp
│ imgui_impl_opengl3.h
│ imgui_impl_opengl3_loader.h
│ imgui_internal.h
│ imgui_tables.cpp
│ imgui_widgets.cpp
│ imstb_rectpack.h
│ imstb_textedit.h
│ imstb_truetype.h
│ main.cpp

├───.vscode
│ tasks.json

task.json

{
  "tasks": [
    {
      "type": "cppbuild",
      "label": "C/C++: g++.exe build active file",
      "command": "C:\\msys64\\mingw64\\bin\\g++.exe",
      "args": [
        "-fdiagnostics-color=always",
        "-std=c++11",
        "-Wall",
        "-Wformat",
        "-g",
        "${fileDirname}\\*.h",
        "${fileDirname}\\*.cpp",
        "${file}",
        "-lglfw3.dll",
        "-o",
        "${fileDirname}\\out\\${fileBasenameNoExtension}I.exe",
        "-lglfw3",
        "-lgdi32",
        "-lopengl32",
        "-limm32"
      ],
      "options": {
        "cwd": "${fileDirname}"
      },
      "problemMatcher": ["$gcc"],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "detail": "Task generated by Debugger."
    }
  ],
  "version": "2.0.0"
}

Install in msys2:

mingw-w64-x86_64-toolchain
mingw-w64-x86_64-freeglut
mingw-w64-x86_64-glew
mingw-w64-x86_64-glfw

Details:

When I compile main.cpp (which is the same example file as examples\example_glfw_opengl3\main.cpp), I get the error:

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\...\AppData\Local\Temp\ccM3ZqIv.o: in function `main':

C:/.../imgui_gl/main.cpp:39: multiple definition of `main'; 

C:\Users\tabit\AppData\Local\Temp\ccDelAIu.o: C:/.../imgui_gl/main.cpp:39: first defined here

collect2.exe: error: ld returned 1 exit status

I've already investigated what I might be doing wrong, and even reinstalled all of imgui, but I haven't been able to fix it.
I hope you can help me solve it.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

static void glfw_error_callback(int error, const char* description)
{
    fprintf(stderr, "GLFW Error %d: %s\n", error, description);
}

// Main code
int main(int, char**) <----------------------------------------
{
    glfwSetErrorCallback(glfw_error_callback);
    if (!glfwInit())
        return 1;

    // Decide GL+GLSL versions
#if defined(IMGUI_IMPL_OPENGL_ES2)
    // GL ES 2.0 + GLSL 100 (WebGL 1.0)
    const char* glsl_version = "#version 100";
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
    glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
#elif defined(IMGUI_IMPL_OPENGL_ES3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions