Undefined reference when linking to mingw libraries

I have installed MinGW and CMake with MSYS2 UCRT64.
I have repeatedly failed to build a GUI application using several libraries: IUP and NAppGUI.

All the problems are of the type, “undefined reference to XXX” when linking. XXX is a function from system libraries (ex: GdipFree, __imp___argc, _setjmp, __imp_GetThemeFont).
I have tried reinstalling MinGW from scoop and still failed to build. I also tried to build using Ninja instead of Make, and failed too.

Currently trying to finish a project at college, any help is appreciated.

NAppGUI build log:

[main] Building folder: nappgui_test 
[main] Configuring project: nappgui_test 
[proc] Executing command: C:msys64ucrt64bincmake.EXE --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:msys64ucrt64bingcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:msys64ucrt64bing++.exe -SC:/Users/avila/nappgui_test -Bc:/Users/avila/nappgui_test/build -G "MinGW Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
[cmake]   Compatibility with CMake < 3.5 will be removed from a future version of
[cmake]   CMake.
[cmake] 
[cmake]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[cmake]   CMake that the project does not need compatibility with older versions.
[cmake] 
[cmake] 
[cmake] Found NAppGUI at 'C:/Users/avila/nappgui'
[cmake]    Version: 1.4.2.5131
[cmake]    Linker: static
[cmake] -- - [OK] napphello: Desktop application
[cmake] -- Configuring done (0.2s)
[cmake] -- Generating done (0.1s)
[cmake] -- Build files have been written to: C:/Users/avila/nappgui_test/build
[build] Starting build
[proc] Executing command: chcp
[proc] Executing command: C:msys64ucrt64bincmake.EXE --build c:/Users/avila/nappgui_test/build --config Debug --target all -j 10 --
[build] [ 33%] Building C object hello/CMakeFiles/napphello.dir/napphello.c.obj
[build] [ 66%] Building RC object hello/CMakeFiles/napphello.dir/res.rc.obj
[build] [100%] Linking CXX executable ..Debugbinnapphello.exe
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/avila/nappgui/lib/libosgui.a(osdrawctrl.cpp.obj): in function `osdrawctrl_font':
[build] C:/Users/avila/nappgui_src/src/osgui/win/osdrawctrl.cpp:57:(.text+0x1007e): undefined reference to `__imp_GetThemeFont'
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/avila/nappgui/lib/libosgui.a(osdrawctrl.cpp.obj): in function `i_sort_size':
[build] C:/Users/avila/nappgui_src/src/osgui/win/osdrawctrl.cpp:211:(.text+0x104bd): undefined reference to `__imp_GetThemePartSize'
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/avila/nappgui/lib/libosgui.a(osgui_win.cpp.obj): in function `osgui_start_imp':
[build] C:/Users/avila/nappgui_src/src/osgui/win/osgui_win.cpp:459:(.text+0x115aa): undefined reference to `__imp_InitCommonControlsEx'
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/avila/nappgui_src/src/osgui/win/osgui_win.cpp:476:(.text+0x11659): undefined reference to `GdiplusStartup'
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/avila/nappgui/lib/libosgui.a(osgui_win.cpp.obj): in function `osgui_finish_imp':
[build] C:/Users/avila/nappgui_src/src/osgui/win/osgui_win.cpp:592:(.text+0x11aa2): undefined reference to `GdiplusShutdown'
.
.
.
[build] collect2.exe: error: ld returned 1 exit status
[build] mingw32-make[2]: *** [helloCMakeFilesnapphello.dirbuild.make:115: Debug/bin/napphello.exe] Error 1
[build] mingw32-make[1]: *** [CMakeFilesMakefile2:97: hello/CMakeFiles/napphello.dir/all] Error 2
[build] mingw32-make: *** [Makefile:135: all] Error 2
[proc] The command: C:msys64ucrt64bincmake.EXE --build c:/Users/avila/nappgui_test/build --config Debug --target all -j 10 -- exited with code: 2
[driver] Build completed: 00:00:04.892
[build] Build finished with exit code 2

IUP build log:

[main] Building folder: iup_test 
[build] Starting build
[proc] Executing command: C:msys64ucrt64bincmake.EXE --build c:/Users/avila/iup_test/build --config Debug --target all --
[build] [1/1 100% :: 0.335] Linking C executable iup_test.exe
[build] FAILED: iup_test.exe 
[build] C:WINDOWSsystem32cmd.exe /C "cd . && C:msys64ucrt64bincc.exe -g  CMakeFiles/iup_test.dir/main.c.obj -o iup_test.exe -Wl,--out-implib,libiup_test.dll.a -Wl,--major-image-version,0,--minor-image-version,0  C:/Users/avila/iup_test/iup/libiup.a  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/avila/iup_test/iup/libiup.a(iupwin_open.o):iupwin_open.c:(.text+0x160): undefined reference to `__imp_InitCommonControlsEx'
.
.
.
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/avila/iup_test/iup/libiup.a(iupwindows_main.o):iupwindows_main.c:(.rdata$.refptr.__imp___argc[.refptr.__imp___argc]+0x0): undefined reference to `__imp___argc'
[proc] The command: C:msys64ucrt64bincmake.EXE --build c:/Users/avila/iup_test/build --config Debug --target all -- exited with code: 1
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/avila/iup_test/iup/libiup.a(iupwindows_main.o):iupwindows_main.c:(.rdata$.refptr.__imp___argv[.refptr.__imp___argv]+0x0): undefined reference to `__imp___argv'
[build] collect2.exe: error: ld returned 1 exit status
[build] ninja: build stopped: subcommand failed.
[driver] Build completed: 00:00:00.428
[build] Build finished with exit code 1

Built and tried to link IUP and NAppGUI example app, but failed. I followed the steps from NAppGUI and IUP tutorial.

New contributor

AvlKP is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật