Skip to content

Fix ImGuiColorTextEdit windows mingw linker error#507

Open
xypwn wants to merge 4 commits intoAllenDang:mainfrom
xypwn:fix-windows-mingw-linker-error
Open

Fix ImGuiColorTextEdit windows mingw linker error#507
xypwn wants to merge 4 commits intoAllenDang:mainfrom
xypwn:fix-windows-mingw-linker-error

Conversation

@xypwn
Copy link

@xypwn xypwn commented Feb 14, 2026

Attempting to use ImGuiColorTextEdit on Windows with mingw caused the linker error shown below (may be related to #418).

I managed to make it run on my system by bypassing the isblank and isascii c lib functions which caused the errors via simple custom implementations (which have the same behavior).

C:\PROGRA~1\Go\pkg\tool\windows_amd64\link.exe: running g++ failed: exit status 1
C:\Users\darwinsc\scoop\apps\gcc\current\bin\g++.exe -m64 -s -mconsole -Wl,--tsaware -Wl,--nxcompat -Wl,--major-os-version=6 -Wl,--minor-os-version=1 -Wl,--major-subsystem-version=6 -Wl,--minor-subsystem-version=1 -Wl,--dynamicbase -Wl,--high-entropy-va -o $WORK\b001\exe\main.exe -Wl,--no-insert-timestamp C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\go.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000000.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000001.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000002.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000003.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000004.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000005.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000006.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000007.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000008.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000009.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000010.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000011.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000012.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000013.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000014.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000015.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000016.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000017.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000018.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000019.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000020.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000021.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000022.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000023.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000024.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000025.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000026.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000027.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000028.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000029.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000030.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000031.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000032.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000033.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000034.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000035.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000036.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000037.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000038.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000039.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000040.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000041.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000042.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000043.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000044.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000045.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000046.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000047.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000048.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000049.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000050.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000051.o C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\000052.o -O2 -g -LC:/Users/darwinsc/go/pkg/mod/github.com/!allen!dang/cimgui-go@v1.4.1-0.20260212022652-b889878a2a53/ImGuiColorTextEdit/../lib/windows/x64 -l:cimgui.a -O2 -g -LC:/Users/darwinsc/go/pkg/mod/github.com/!allen!dang/cimgui-go@v1.4.1-0.20260212022652-b889878a2a53/imgui/../lib/windows/x64 -l:cimgui.a -O2 -g -O2 -g -ldwmapi -O2 -g -O2 -g -O2 -g -O2 -g -LC:/Users/darwinsc/go/pkg/mod/github.com/!allen!dang/cimgui-go@v1.4.1-0.20260212022652-b889878a2a53/backend/../lib/windows/x64 -l:cimgui.a -O2 -g -LC:/Users/darwinsc/go/pkg/mod/github.com/!allen!dang/cimgui-go@v1.4.1-0.20260212022652-b889878a2a53/backend/glfwbackend/../../lib/windows/x64 -l:cimgui.a -LC:/Users/darwinsc/go/pkg/mod/github.com/!allen!dang/cimgui-go@v1.4.1-0.20260212022652-b889878a2a53/backend/glfwbackend/../../lib/windows/x64 -l:libglfw3.a -lgdi32 -lopengl32 -limm32 -O2 -g -lopengl32 -lopengl32 -Wl,-T,C:\Users\darwinsc\AppData\Local\Temp\go-link-80615885\fix_debug_gdb_scripts.ld -Wl,--start-group -lmingwex -lmingw32 -Wl,--end-group -lkernel32
C:/Users/darwinsc/scoop/apps/gcc/13.2.0/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/darwinsc/go/pkg/mod/github.com/!allen!dang/cimgui-go@v1.4.1-0.20260212022652-b889878a2a53/ImGuiColorTextEdit/../lib/windows/x64\cimgui.a(TextEditor.cpp.obj):TextEditor.cpp:(.text+0x11272): undefined reference to `__imp_isblank'
C:/Users/darwinsc/scoop/apps/gcc/13.2.0/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/darwinsc/go/pkg/mod/github.com/!allen!dang/cimgui-go@v1.4.1-0.20260212022652-b889878a2a53/ImGuiColorTextEdit/../lib/windows/x64\cimgui.a(LanguageDefinitions.cpp.obj):LanguageDefinitions.cpp:(.text+0x2dd): undefined reference to `__imp_isblank'
C:/Users/darwinsc/scoop/apps/gcc/13.2.0/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/darwinsc/go/pkg/mod/github.com/!allen!dang/cimgui-go@v1.4.1-0.20260212022652-b889878a2a53/ImGuiColorTextEdit/../lib/windows/x64\cimgui.a(LanguageDefinitions.cpp.obj):LanguageDefinitions.cpp:(.text+0x4fd): undefined reference to `__imp_isblank'
C:/Users/darwinsc/scoop/apps/gcc/13.2.0/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/darwinsc/go/pkg/mod/github.com/!allen!dang/cimgui-go@v1.4.1-0.20260212022652-b889878a2a53/ImGuiColorTextEdit/../lib/windows/x64\cimgui.a(LanguageDefinitions.cpp.obj):LanguageDefinitions.cpp:(.text+0x8ad): undefined reference to `__imp_isblank'
collect2.exe: error: ld returned 1 exit status

@xypwn xypwn changed the title Fix windows mingw linker error Fix ImGuiColorTextEdit windows mingw linker error Feb 14, 2026
Copy link
Collaborator

@gucio321 gucio321 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello!
Thank you for your pull request
Unfortunately, cwrappers directory contains "external C++ code" that we'd rather not modify. The reason is that running make update will override those changes.
Could you please report this to the upstream?
Alternatively, maybe try to put those changes directly in ImGuiColorTextEdit (e.g. custom.go or something)

Also, if related to #418, what mingw version? As mentioned in #418 (comment) it worked for me (at that point). I can try again tomorrow on the current codebase.

@xypwn
Copy link
Author

xypwn commented Feb 14, 2026

Hi, thanks for the quick response. I didn't know this repo had a make update, so your reasoning makes sense.

I'm using the current scoop distribution of gcc (version 13.2.0), which targets x86_64-w64-mingw32.

Also, it turns out I actually don't get the linker error if I recompile the cimgui.a library on my local machine (instead of ci), so it seems to be some weird interaction between the different linker/compiler versions. This means fixing in the C++ upstream probably doesn't make much sense, since users won't have mismatching compiler/linker versions there anyway.

I doubt it's possible to do anything from the Go/CGo side as you proposed, since the error stems from cimgui.a, which is built from CMake.

I don't know what else to do, though, but I understand why you may not want to merge in this state. I'm open to any other ideas.

@gucio321
Copy link
Collaborator

gucio321 commented Feb 15, 2026

well, I tried again and it still works on arch linux.

My analysis:

      - name: Install MinGW
        uses: msys2/setup-msys2@v2
        with:
          update: true
          install: >-
            make
            git
          pacboy: >-
            toolchain:p
            cmake:p
            ninja:p
  • I'm not quite sure what is the exact gcc version it uses, but strings cimgui.a |grep -i gcc says GCC: (Rev8, Built by MSYS2 project) 15.2.0, so I suppose that according to semver you are supposed to use gcc >= 15.0.0 (this is also because it works on arch which has x86_64-w64-mingw32-gcc (GCC) 15.2.0)

Generally I agree that requiring to have latest gcc is not the best thing we can do here - we deffinitly should support older versions - this is why #157 exists but we have no idea how to do this atm.

As a workeround, I suggest using docker (or custom mingw version)

FROM archlinux:latest

RUN pacman -Syu --noconfirm git go glfw mingw-w64-gcc

RUN git clone https://github.com/AllenDang/cimgui-go /cimgui-go ## clone your project here or use ADD

WORKDIR /cimgui-go/examples/glfw

ENV GOOS=windows
ENV GOARCH=amd64
ENV CGO_ENABLED=1
ENV CC=x86_64-w64-mingw32-gcc
ENV CXX=x86_64-w64-mingw32-g++
ENV HOST=x86_64-w64-mingw32

CMD go build -ldflags "-s -w -H=windowsgui -extldflags=-static" -p 4 -v -o test.exe

@xypwn
Copy link
Author

xypwn commented Feb 15, 2026

Thank you for the elaborate answer and suggestions. It turns out my scoop package manager was broken and therefore refused to update my GCC version (it works now with the latest version). So I guess it's up to you maintainers how important you think supporting older GCC versions is.

EDIT: Actually, it turns out it still doesn't link (I didn't properly save my go.mod when testing). I still get the __imp_isblank linker error, even using x86_64-w64-mingw32 gcc/g++/ld v15.2.0 (I explicitly triple-checked the version). I am utterly confused and have no idea why this doesn't work.

I also did a bit more research on the topic in general and it turns out glibc is not at all intended to be forward-compatible (my proposed fix was just a lucky simple solution to a more general issue). However glibc it IS meant to be backward-compatible (older for cimgui.a, newer for CGo). This means compiling cimgui.a from a slightly older GCC version would probably significantly increase the number of Windows setups cimgui.a links on.

@gucio321
Copy link
Collaborator

Could you try with a fresh clone of cimgui-go and with go build -a?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments