Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc seems broken #10761

Open
omichel opened this issue Feb 16, 2022 · 80 comments
Open

gcc seems broken #10761

omichel opened this issue Feb 16, 2022 · 80 comments

Comments

@omichel
Copy link
Contributor

omichel commented Feb 16, 2022

After updating MSYS2 this morning, I cannot compile my app any more, getting this error:

C:/msys64/mingw64/include/c++/11.2.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
   75 | #include_next <stdlib.h>
      |               ^~~~~~~~~~
@Biswa96
Copy link
Member

Biswa96 commented Feb 16, 2022

There is a core change in system crt and headers. So, GCC is being rebuilt in CI right now. Please wait for the fix.

@omichel
Copy link
Contributor Author

omichel commented Feb 16, 2022

OK, thank you for the quick reply!

@class101
Copy link

class101 commented Feb 16, 2022

@Biswa96

Is it related to the following behavior or do I need to open a newer ticket for this ?

mingw-w64-ucrt-x86_64-headers-git -> 9.0.0.6364_.2194d504e-1

headers are located in tar/ucrt64/x86_64-w64-mingw32/include

mingw-w64-ucrt-x86_64-headers-git -> 9.0.0.6373.5be8fcd83-1

headers are also located in tar/ucrt64/x86_64-w64-mingw32/include

mingw-w64-ucrt-x86_64-headers-git -> 9.0.0.6373.5be8fcd83-2

headers are relocated to tar/ucrt64/include

Thank you for helping

PS: @omichel If this is same behavior, a temp fix is to symlink x86_64-w64-mingw32/include to ..\include

@lazka
Copy link
Member

lazka commented Feb 16, 2022

Oh, I didn't realize that the gcc update was needed since I build various things without it locally.

I'll look into updating things

@lazka
Copy link
Member

lazka commented Feb 16, 2022

Please try again now.

@omichel
Copy link
Contributor Author

omichel commented Feb 17, 2022

Nope: I am still getting the exact same error after updating to the latest gcc packages:

$ pacman -Syuu
:: Synchronizing package databases...
 mingw32              1448.3 KiB   559 KiB/s 00:03 [#####################] 100%
 mingw64              1455.3 KiB  1704 KiB/s 00:01 [#####################] 100%
 ucrt64               1587.8 KiB  2.70 MiB/s 00:01 [#####################] 100%
 clang64              1500.3 KiB   889 KiB/s 00:02 [#####################] 100%
 msys is up to date
:: Starting core system upgrade...
 there is nothing to do
:: Starting full system upgrade...
resolving dependencies...
looking for conflicting packages...

Packages (5) mingw-w64-i686-gcc-11.2.0-9  mingw-w64-i686-gcc-libs-11.2.0-9
             mingw-w64-x86_64-gcc-11.2.0-9
             mingw-w64-x86_64-gcc-libgfortran-11.2.0-9
             mingw-w64-x86_64-gcc-libs-11.2.0-9

Total Download Size:    60.12 MiB
Total Installed Size:  338.72 MiB
Net Upgrade Size:       -0.01 MiB

:: Proceed with installation? [Y/n]
:: Retrieving packages...
 mingw-w64-x86_64...   761.0 KiB   713 KiB/s 00:01 [#####################] 100%
 mingw-w64-x86_64...   827.8 KiB   734 KiB/s 00:01 [#####################] 100%
 mingw-w64-i686-g...   886.5 KiB   730 KiB/s 00:01 [#####################] 100%
 mingw-w64-x86_64...    28.5 MiB  5.64 MiB/s 00:05 [#####################] 100%
 mingw-w64-i686-g...    29.2 MiB  3.65 MiB/s 00:08 [#####################] 100%
 Total (5/5)            60.1 MiB  7.49 MiB/s 00:08 [#####################] 100%
(5/5) checking keys in keyring                     [#####################] 100%
(5/5) checking package integrity                   [#####################] 100%
(5/5) loading package files                        [#####################] 100%
(5/5) checking for file conflicts                  [#####################] 100%
(5/5) checking available disk space                [#####################] 100%
:: Processing package changes...
(1/5) upgrading mingw-w64-i686-gcc-libs            [#####################] 100%
(2/5) upgrading mingw-w64-i686-gcc                 [#####################] 100%
(3/5) upgrading mingw-w64-x86_64-gcc-libs          [#####################] 100%
(4/5) upgrading mingw-w64-x86_64-gcc               [#####################] 100%
(5/5) upgrading mingw-w64-x86_64-gcc-libgfortran   [#####################] 100%
...
$ make
...
In file included from C:/msys64/mingw64/include/c++/11.2.0/bits/stl_algo.h:59,
                 from C:/msys64/mingw64/include/c++/11.2.0/algorithm:62,
                 from ../../include/qt/QtCore/QtCore/qglobal.h:137,
                 from ../../include/qt/QtCore/QtCore/qpair.h:43,
                 from ../../include/qt/QtCore/QtCore/qarraydata.h:44,
                 from ../../include/qt/QtCore/QtCore/qarraydataops.h:44,
                 from ../../include/qt/QtCore/QtCore/qarraydatapointer.h:43,
                 from ../../include/qt/QtCore/QtCore/qlist.h:44,
                 from ../../include/qt/QtCore/QtCore/QList:1,
                 from sound/WbContactSoundManager.hpp:22,
                 from sound/WbSoundEngine.cpp:17:
C:/msys64/mingw64/include/c++/11.2.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
   75 | #include_next <stdlib.h>
      |               ^~~~~~~~~~

@lazka
Copy link
Member

lazka commented Feb 17, 2022

thanks, yeah, something is still off.

I can't reproduce though.

@lazka
Copy link
Member

lazka commented Feb 17, 2022

@class101 those relocations are on purpose, see #10634

@Biswa96
Copy link
Member

Biswa96 commented Feb 17, 2022

@omichel Please provide the project link and details about how to compile it.

@omichel
Copy link
Contributor Author

omichel commented Feb 17, 2022

It's there: https://github.com/cyberbotics/webots/wiki/Windows-installation/
It should be pretty easy to proceed as many tasks are automatic. Let me know if you have any question.

@class101
Copy link

GCC upgrade to 11.2.0-9

Ty @lazka @Biswa96 but it still breaks for me with the latest gcc upgrade you pushed, it looks like similar to the issue @omichel is having

Unexpected behavior

CLion is no more capable of using a MinGW toolchain under Windows and is displaying the message Not found
image

Log of what is behind "Not found"

I enabled the log of category #com.jetbrains.cidr.cpp and found the following relevant issue

2022-02-17 10:19:47,928 [ 625373]   INFO -        #com.jetbrains.cidr.cpp - No output for command: C:\tools\clion\bin\cmake\win\bin\cmake.exe -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY -G "NMake Makefiles" C:\Users\ufleadv\AppData\Local\Temp\cmake_check_environment 
2022-02-17 10:19:48,568 [ 626013]  DEBUG -        #com.jetbrains.cidr.cpp - MinGW.readVersion() file: 'C:\tools\msys2\ucrt64' error 
java.io.FileNotFoundException: C:\tools\msys2\ucrt64\x86_64-w64-mingw32\include\_mingw.h (Le chemin d’accès spécifié est introuvable)
	at java.base/java.io.FileInputStream.open0(Native Method)

@class101
Copy link

class101 commented Feb 17, 2022

Edit: Issue reported to the CLion team here https://youtrack.jetbrains.com/issue/CPP-28403

@Biswa96

indeed I think CLion checks for a static file location for checking the validity of the toolchain because that's what show the Java stacktrace

java.io.FileNotFoundException: C:\tools\msys2\ucrt64\x86_64-w64-mingw32\include\_mingw.h (Le chemin d’accès spécifié est introuvable)
	at java.base/java.io.FileInputStream.open0(Native Method)
	at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
	at com.intellij.openapi.util.io.FileUtilRt.loadFileText(FileUtilRt.java:755)
	at com.intellij.openapi.util.io.FileUtilRt.loadFile(FileUtilRt.java:744)
	at com.intellij.openapi.util.io.FileUtilRt.loadFile(FileUtilRt.java:729)
	at com.intellij.openapi.util.io.FileUtil.loadFile(FileUtil.java:1405)
	at com.jetbrains.cidr.cpp.toolchains.MinGW.readVersion(MinGW.java:108)
	at com.jetbrains.cidr.cpp.toolchains.MinGW.readVersion(MinGW.java:88)
	at com.jetbrains.cidr.cpp.toolchains.ui.ToolchainPanel$3.readAndCheckVersion(ToolchainPanel.kt:317)
	at com.jetbrains.cidr.cpp.toolchains.ui.ToolchainPanel$3.readAndCheckVersion(ToolchainPanel.kt:311)
	at com.jetbrains.cidr.cpp.toolchains.VersionChecker.check(CPPToolchainsUIUtils.kt:193)
	at com.jetbrains.cidr.cpp.toolchains.ui.ToolchainPanel$addVersionChecker$checkerRunnable$1.runInBackground(ToolchainPanel.kt:648)
	at com.jetbrains.cidr.cpp.toolchains.ui.ToolchainPanel$addVersionChecker$checkerRunnable$1.runInBackground(ToolchainPanel.kt:641)
	at com.jetbrains.cidr.cpp.toolchains.ui.ToolchainPanel$addChecker$runnable$1$run$1$backgroundFunction$1.invoke(ToolchainPanel.kt:861)
	at com.jetbrains.cidr.cpp.toolchains.ui.ToolchainPanel$addChecker$runnable$1$run$1$backgroundFunction$1.invoke(ToolchainPanel.kt:836)
	at com.jetbrains.cidr.cpp.toolchains.ui.ToolchainPanel$sam$java_lang_Runnable$0.run(ToolchainPanel.kt)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:624)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:698)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:646)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:623)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
	at com.jetbrains.cidr.cpp.toolchains.ui.ToolchainPanel$addChecker$runnable$1$run$1.run(ToolchainPanel.kt:862)
	at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:240)
	at com.intellij.util.Alarm$Request.runSafely(Alarm.java:385)
	at com.intellij.util.Alarm$Request.run(Alarm.java:374)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:220)
	at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:246)
	at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:32)
	at com.intellij.util.concurrency.BoundedTaskExecutor$1.execute(BoundedTaskExecutor.java:225)
	at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:213)

Ty for helping out guys, I think I don't have a better solution yet than creating a symlink while waiting for the newest CLion 2022.1 :)

@SirLynix
Copy link
Contributor

I'm having the same issue with my MinGW64 CI: https://github.com/DigitalPulseSoftware/NazaraEngine/runs/5231389195?check_suite_focus=true#step:10:52

@Biswa96
Copy link
Member

Biswa96 commented Feb 17, 2022

@SirLynix If I run xmake it starts to build all the dependencies. Some of them are already in mingw packages. Is it possible not to build all those dependencies from source? BTW, it may be better to discuss an issue in that repository. This thread will be going longer.

@SirLynix
Copy link
Contributor

@SirLynix If I run xmake it starts to build all the dependencies. Some of them are already in mingw packages. Is it possible not to build all those dependencies from source? BTW, it may be better to discuss an issue in that repository. This thread will be going longer.

Sure.
XMake should be able to detect already installed libraries, could you tell me which libraries were already on your system and were recompiled by xmake?

@Biswa96
Copy link
Member

Biswa96 commented Feb 17, 2022

I ran this:

xmake config --shadernodes=y --tests=y --arch=x86_64 --mode=releasedbg --verbose --yes --plat=mingw --mingw=/ucrt64

First, it tries to build assimp. In the output, all the dependencies are shown in red no.

@SirLynix
Copy link
Contributor

It should give you a list of the missing packages before installing them, was there only assimp on it?

Since this isn't relevant to this issue, feel free to send me a mail or open an issue on my repository.

@lock042
Copy link
Contributor

lock042 commented Feb 17, 2022

I think I ran into the same experience:

-- The CXX compiler identification is GNU 10.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /builds/free-astro/siril/.local/share/crossroad/bin/x86_64-w64-mingw32-g++
-- Check for working CXX compiler: /builds/free-astro/siril/.local/share/crossroad/bin/x86_64-w64-mingw32-g++ - broken
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
  The C++ compiler

    "/builds/free-astro/siril/.local/share/crossroad/bin/x86_64-w64-mingw32-g++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /builds/free-astro/siril/subprojects/librtprocess/_build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_e4c38/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_e4c38.dir/build.make CMakeFiles/cmTC_e4c38.dir/build
    gmake[1]: Entering directory '/builds/free-astro/siril/subprojects/librtprocess/_build/CMakeFiles/CMakeTmp'
    Building CXX object CMakeFiles/cmTC_e4c38.dir/testCXXCompiler.cxx.obj
    /builds/free-astro/siril/.local/share/crossroad/bin/x86_64-w64-mingw32-g++    -o CMakeFiles/cmTC_e4c38.dir/testCXXCompiler.cxx.obj -c /builds/free-astro/siril/subprojects/librtprocess/_build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
    Linking CXX executable cmTC_e4c38.exe
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e4c38.dir/link.txt --verbose=1
    /usr/bin/cmake -E rm -f CMakeFiles/cmTC_e4c38.dir/objects.a
    /usr/bin/x86_64-w64-mingw32-ar qc CMakeFiles/cmTC_e4c38.dir/objects.a @CMakeFiles/cmTC_e4c38.dir/objects1.rsp
    /builds/free-astro/siril/.local/share/crossroad/bin/x86_64-w64-mingw32-g++ -Wl,--whole-archive CMakeFiles/cmTC_e4c38.dir/objects.a -Wl,--no-whole-archive -o cmTC_e4c38.exe -Wl,--out-implib,libcmTC_e4c38.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles/cmTC_e4c38.dir/linklibs.rsp
    /usr/bin/x86_64-w64-mingw32-ld: /usr/lib/gcc/x86_64-w64-mingw32/10-posix/../../../../x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.rdata$.refptr.mingw_app_type[.refptr.mingw_app_type]+0x0): undefined reference to `mingw_app_type'
    /usr/bin/x86_64-w64-mingw32-ld: /usr/lib/gcc/x86_64-w64-mingw32/10-posix/../../../../x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.rdata$.refptr.mingw_initcharmax[.refptr.mingw_initcharmax]+0x0): undefined reference to `mingw_initcharmax'
    /usr/bin/x86_64-w64-mingw32-ld: /usr/lib/gcc/x86_64-w64-mingw32/10-posix/../../../../x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltssuo_force[.refptr.mingw_initltssuo_force]+0x0): undefined reference to `mingw_initltssuo_force'
    /usr/bin/x86_64-w64-mingw32-ld: /usr/lib/gcc/x86_64-w64-mingw32/10-posix/../../../../x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltsdyn_force[.refptr.mingw_initltsdyn_force]+0x0): undefined reference to `mingw_initltsdyn_force'
    /usr/bin/x86_64-w64-mingw32-ld: /usr/lib/gcc/x86_64-w64-mingw32/10-posix/../../../../x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltsdrot_force[.refptr.mingw_initltsdrot_force]+0x0): undefined reference to `mingw_initltsdrot_force'
    collect2: error: ld returned 1 exit status
    gmake[1]: *** [CMakeFiles/cmTC_e4c38.dir/build.make:101: cmTC_e4c38.exe] Error 1
    gmake[1]: Leaving directory '/builds/free-astro/siril/subprojects/librtprocess/_build/CMakeFiles/CMakeTmp'
    gmake: *** [Makefile:127: cmTC_e4c38/fast] Error 2
    

https://gitlab.com/free-astro/siril/-/jobs/2107398233

But difficult to say as the output is different.
Is this something that will be fixed? Or need I to change something?

@lazka : maybe the log could help you to reproduce.

@waruqi
Copy link
Contributor

waruqi commented Feb 17, 2022

I had a similar problem, building libtiff on mingw ci failed, stdint.h not found

But it worked a few days ago.

https://github.com/xmake-io/xmake-repo/runs/5234506913?check_suite_focus=true

-- Looking for stdint.h
-- Looking for stdint.h - not found
-- Looking for stddef.h
-- Looking for stddef.h - not found
-- Check size of size_t
-- Check size of size_t - failed
CMake Error at cmake/TypeSizeChecks.cmake:51 (message):
  Unsupported size_t size ; please add support
git clone https://github.com/xmake-io/xmake-repo.git
cd xmake-repo
xmake l scripts/test.lua -vD --shallow -p mingw libtiff

@Biswa96
Copy link
Member

Biswa96 commented Feb 18, 2022

@waruqi I am not sure what happen in xmake. I have compiled libtiff from source using CMake and Ninja and it builds fine. Here are my steps:

git clone --depth=1 https://gitlab.com/libtiff/libtiff.git
cd libtiff
cmake -B build -S .
ninja -C build

And here is the same output in cmake where xmake failed.

-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of size_t
-- Check size of size_t - done

@Biswa96
Copy link
Member

Biswa96 commented Feb 18, 2022

@lock042 /usr/bin/x86_64-w64-mingw32-ld is not the path of mingw compiler in msys2. It seems that you are using cross compiler in Linux environment.

@lock042
Copy link
Contributor

lock042 commented Feb 18, 2022

@Biswa96 : yes I use crossroad that uses Msys2.
The CI failed after Msys2 update.

@Biswa96
Copy link
Member

Biswa96 commented Feb 18, 2022

I use crossroad that uses Msys2.

Then the issue should be reported crossroad. Feel free to ping me there. Or you can also use msys2 in GitLab. Many projects like pango, gstreamer etc. use msys2 in GitLab CI.

@omichel
Copy link
Contributor Author

omichel commented Feb 18, 2022

I managed to reduce the problem to a very simple hello_world.cpp example:

/*
g++ -isystem /mingw64/include hello_world.cpp -o hello_world.exe
fails with:
In file included from C:/msys64/mingw64/include/c++/11.2.0/bits/stl_algo.h:59,
                 from C:/msys64/mingw64/include/c++/11.2.0/algorithm:62,
                 from C:/msys64/mingw64/include/QtCore/qglobal.h:142,
                 from C:/msys64/mingw64/include/QtCore/qchar.h:43,
                 from C:/msys64/mingw64/include/QtCore/qstring.h:49,
                 from C:/msys64/mingw64/include/QtCore/QString:1,
                 from hello_world.cpp:5:
C:/msys64/mingw64/include/c++/11.2.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
   75 | #include_next <stdlib.h>
      |               ^~~~~~~~~~
compilation terminated.

Removing "-isystem /mingw64/include" fixes the problem

*/

#include <QtCore/QString>

int main(int argc, char *argv[]) {
  printf("Hello World!\n");
  return 1;
}

@Biswa96
Copy link
Member

Biswa96 commented Feb 18, 2022

/include/c++/11.2.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory

Sounds like an gcc issue https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129

@omichel
Copy link
Contributor Author

omichel commented Feb 18, 2022

Sounds like an gcc issue https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129

Yes, luckily the fix is very simple: remove -isystem /mingw64/include. I just applied it here so that we can compile our application again.

We can probably close the issue now.

@waruqi
Copy link
Contributor

waruqi commented Feb 18, 2022

@waruqi I am not sure what happen in xmake. I have compiled libtiff from source using CMake and Ninja and it builds fine. Here are my steps:

git clone --depth=1 https://gitlab.com/libtiff/libtiff.git
cd libtiff
cmake -B build -S .
ninja -C build

And here is the same output in cmake where xmake failed.

-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of size_t
-- Check size of size_t - done

It will set -DCMAKE_SYSROOT=D:/a/_temp/msys64/mingw64 as sysroot to cmake when I am running xmake to call cmake to build libtiff on my msys/mingw ci.

If I set CMAKE_SYSROOT, this problem comes up, If I remove it, everything works fine.

But a few days ago everything was ok and I didn't make any other changes. It works fine even with CMAKE_SYSROOT set.

@Biswa96
Copy link
Member

Biswa96 commented Feb 18, 2022

If I set CMAKE_SYSROOT, this problem comes up, If I remove it, everything works fine.

So, it is not required anymore, isn't that a feature? 😄 As far as I know, CMAKE_SYSROOT passes --sysroot option to compiler to find system headers and libs. It is required to say like, hey compiler, instead of searching /usr/include, search /mydir/usr/include. More here https://sourceforge.net/p/mingw-w64/wiki2/Native%20Win64%20compiler/

@lazka
Copy link
Member

lazka commented Aug 6, 2022

also noticed it in some sources using meson so my guess is no ?.

Do you remember which project? In theory meson filters out isystem. Meson can also call into cmake via subprojects though, maybe that way?

@revelator
Copy link
Contributor

not of the top of my head sorry :/ but yeah it could have done that.

@revelator
Copy link
Contributor

several packages have none existing sources links in the PKGBUILDS pcre for one but there are several others. also some packages can no longer build with the updated libraries like cninja which is looking for a no longer existing file in catch2.

sadly i cannot give much further help on the gcc problem as i reverted the path changes locally, so im not experiencing the problems we had before anymore.

@revelator
Copy link
Contributor

no not that one it is looking for catch.hpp which no longer exists it is now called catch-all.hpp

@lazka
Copy link
Member

lazka commented Oct 16, 2022

I've created #13608 for the cmake issue.

If there is anything else unsolved here I'd be grateful if it would be extracted into a separate issue as well, so we can close this.

@revelator
Copy link
Contributor

only the allready mentioned issues cninja etc. tbh i newer quite get why we had to change the way system libraries was handled ? it worked as it was. Now we have to create workarounds for any package that deviates from the structure of the new system.

loonycyborg added a commit to wesnoth/wesnoth that referenced this issue Oct 22, 2022
msys2 pkg-config adds root system include path among -I flags and
passing it with -isystem isn't supported by gcc, and
the workaround of passing --dont-define-prefix to pkg-config doesn't
work on msys2's "subsystem" install of scons because posix style
absolute paths aren't handled properly when expanding CPPPATH.
Most likely related to msys2/MINGW-packages#10761
@p4ulor
Copy link

p4ulor commented Jan 8, 2023

I have a similar issue, could anyone help me?

 gcc main.c
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x197): undefined reference to `json_delete'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x245): undefined reference to `__imp_curl_global_init'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x24e): undefined reference to `__imp_curl_easy_init'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x292): undefined reference to `__imp_curl_easy_setopt'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x2bf): undefined reference to `__imp_curl_easy_setopt'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x2d2): undefined reference to `__imp_curl_easy_perform'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x2f3): undefined reference to `__imp_curl_easy_strerror'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x32c): undefined reference to `__imp_curl_easy_cleanup'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x335): undefined reference to `__imp_curl_global_cleanup'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x3c5): undefined reference to `json_loadf'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x457): undefined reference to `json_object_get'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x4a5): undefined reference to `json_integer_value'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x4c2): undefined reference to `json_integer_value'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x4dd): undefined reference to `json_object_get'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x4ed): undefined reference to `json_string_value'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x538): undefined reference to `json_object_get'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x548): undefined reference to `json_number_value'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x568): undefined reference to `json_object_get'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x578): undefined reference to `json_string_value'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x61c): undefined reference to `json_object_get'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x62c): undefined reference to `json_integer_value'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x674): undefined reference to `json_object_get'
C:/ProgramsSalad/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\PAULOR~1\AppData\Local\Temp\ccgkawN0.o:main.c:(.text+0x693): undefined reference to `json_array_get'
collect2.exe: error: ld returned 1 exit status

image
image
I can access the header files, it's just when running its not found.
image
It appears that it's always referencing the "x86_64-w64-mingw32" idk why... which only has a bin/ and lib/ folder inside...
image

@1480c1
Copy link
Contributor

1480c1 commented Jan 9, 2023

Does not seem to be exactly linked to this issue, rather it seems you may just have issues with linking, not with the headers. You may want to research more on linking in general, but as a start point, I would suggest looking into how to use pkg-config.

If you want an exact answer, try running

gcc $(pkgconf --static --cflags jansson libcurl) main.c $(pkgconf --static --libs jansson libcurl)

instead of just gcc main.c. The output of the command pkgconf --static --libs jansson libcurl will tell gcc which libraries you will need to be able to link against jansson and curl.

@lotest
Copy link

lotest commented Jun 4, 2024

why need "include_next" in these files? It makes me almost uninstall msys2 again.
I just change #inlcude_next <stdlib.h> to #include "stdlib.h", my code works.

@mati865
Copy link
Collaborator

mati865 commented Jun 4, 2024

@lotest this is how GCC developers implemented inclusion of stdlib.h provided by the system's C library (typically glibc/musl on Linux and mingw-w64 on Windows). Otherwise /ucrt64/include/c++/14.1.0/stdlib.h would be used instead of /ucrt64/include/stdlib.h.
Perhaps your build system messes up include paths? It'd be useful to have a reproducible example.

As another thing to try, I'd suggest adding GCC to the beginning of your PATH. If it's absent, the search paths don't seem correct (it doesn't print anything):

# proving there is no GCC in PATH
$ gcc -v
bash: gcc: command not found

$ /h/msys64/ucrt64/bin/gcc -xc++ -E -v -
Using built-in specs.
COLLECT_GCC=H:\msys64\ucrt64\bin\gcc.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-14.1.0/configure --prefix=/ucrt64 --with-local-prefix=/ucrt64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/ucrt64/include --libexecdir=/ucrt64/lib --enable-bootstrap --enable-checking=release --with-arch=nocona --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,rust,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-libssp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/ucrt64 --with-mpfr=/ucrt64 --with-mpc=/ucrt64 --with-isl=/ucrt64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --enable-plugin --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.1.0 (Rev3, Built by MSYS2 project)
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=nocona'
 H:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/cc1plus.exe -E -quiet -v -iprefix H:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/ -D_REENTRANT - -mtune=generic -march=nocona -dumpbase -

$ PATH=/h/msys64/ucrt64/bin:$PATH /h/msys64/ucrt64/bin/gcc -xc++ -E -v -
Using built-in specs.
COLLECT_GCC=H:\msys64\ucrt64\bin\gcc.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-14.1.0/configure --prefix=/ucrt64 --with-local-prefix=/ucrt64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/ucrt64/include --libexecdir=/ucrt64/lib --enable-bootstrap --enable-checking=release --with-arch=nocona --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,rust,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-libssp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/ucrt64 --with-mpfr=/ucrt64 --with-mpc=/ucrt64 --with-isl=/ucrt64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --enable-plugin --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.1.0 (Rev3, Built by MSYS2 project)
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=nocona'
 H:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/cc1plus.exe -E -quiet -v -iprefix H:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/ -D_REENTRANT - -mtune=generic -march=nocona -dumpbase -
ignoring nonexistent directory "H:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/include"
ignoring duplicate directory "H:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../include/c++/14.1.0"
ignoring duplicate directory "H:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../include/c++/14.1.0/x86_64-w64-mingw32"
ignoring duplicate directory "H:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../include/c++/14.1.0/backward"
ignoring duplicate directory "H:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/14.1.0/include"
ignoring nonexistent directory "D:/a/msys64/ucrt64/include"
ignoring nonexistent directory "/ucrt64/include"
ignoring duplicate directory "H:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/14.1.0/include-fixed"
ignoring nonexistent directory "H:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "D:/a/msys64/ucrt64/include"
#include "..." search starts here:
#include <...> search starts here:
 H:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../include/c++/14.1.0
 H:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../include/c++/14.1.0/x86_64-w64-mingw32
 H:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../include/c++/14.1.0/backward
 H:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/include
 H:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../include
 H:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/include-fixed
End of search list.
# 0 "<stdin>

With proper PATH you can see H:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../include/c++/14.1.0/stdlib.h would be included first and then it'd include (only when using include_next) H:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/include/stdlib.h.

@lotest
Copy link

lotest commented Jun 7, 2024

@mati865 Appreciate for your reply with detail information!

I can reproduce the error when using "/mingw64". In my code, just include and <SDL2/SDL.h> then compile, the "include_next" issue comes out, the simple solution is replace include_next to include.

And I changed my system to /ucrt64 ,follow your instruction, my code could run perfectly. Thanks a lot!

@xmaxrayx
Copy link

xmaxrayx commented Oct 16, 2024

can someone explain Why theses files is missing I installed the gcc via Mysys2 and made sure is all updated.
Idk why people say C is a hard language but understandable if "where is the missing files" is always a problem.

#include <windows.h>

#include <shellscalingapi.h>
#include <stdio.h>

int main() {
    // Set the process to be DPI aware
    SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);

    char name[] = "Max";
    MessageBoxA(0, name, "AAA", 1);
    ShellMessageBoxA(0, 0, "ssss", "hhh", 0);
    printf("%s", name);

    return 0;
}

missing files

  • <_mingw.h>
  • <_mingw_unicode.h>
    how I can get theses ? I read I can copy-paste but worry if it's not safe thing to do since I dont want read the

@xmaxrayx
Copy link

should I copy-paste this?
https://github.com/luzexi/MinGW

@revelator
Copy link
Contributor

uh no you need the mingw compiler and api packages from here.
in particular the mingw-w64-headers-git and mingw-w64-crt-git packages, you can get those with the pacman command in an msys2 shell. there should be a pacman command that gets both the mingw compilers and the minimum needed packages but i cannot remember it.

@mati865
Copy link
Collaborator

mati865 commented Oct 16, 2024

@xmaxrayx can you post full compiler output when building your code with added -v?

@revelator
Copy link
Contributor

indeed the config.log would tell us much :)
btw installing gcc as in pacman -S gcc gets you the msys compiler not the mingw one so that might have been the problem.
the mingw compiler uses pacman -S mingw-w64-gcc where arch is i686 or x86_64 or aarch etc. i686 is the 32 bit version of it the others are for various 64 bit environments but the x86_64 one is for windows.

basic C is not that hard agreed ;) but like with C++ you can make code that is extremely hard to comprehend for others.
Msys2 uses a ton of compilers for everything from C/C++ to go ada fortran rust you name it.

@xmaxrayx
Copy link

xmaxrayx commented Oct 17, 2024

@xmaxrayx can you post full compiler output when building your code with added -v?

idk why it tries to search in D:\\
,even there isn't a there,
,>< wired ...

EDIT : I see why now because my code files there

-v output

using : gcc -v "Hellow world.c"
output :

PS D:\MaxLife\Programming\Learn\C> gcc -v "Hellow world.c"
Using built-in specs.
COLLECT_GCC=C:\msys64\ucrt64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-13.2.0/configure --prefix=/ucrt64 --with-local-prefix=/ucrt64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/ucrt64/include --libexecdir=/ucrt64/lib --enable-bootstrap --enable-checking=release --with-arch=nocona --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-libssp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/ucrt64 --with-mpfr=/ucrt64 --with-mpc=/ucrt64 --with-isl=/ucrt64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Rev3, Built by MSYS2 project)
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=nocona' '-dumpdir' 'a-'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/cc1.exe -quiet -v -iprefix C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/ -D_REENTRANT Hellow world.c -quiet -dumpdir a- -dumpbase Hellow world.c -dumpbase-ext .c -mtune=generic -march=nocona -version -o C:\Users\MAX_LA~1\AppData\Local\Temp\ccZTHxVc.s
GNU C17 (Rev3, Built by MSYS2 project) version 13.2.0 (x86_64-w64-mingw32)
       compiled by GNU C version 13.2.0, GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version isl-0.26-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/include"
ignoring duplicate directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.2.0/include"
ignoring nonexistent directory "D:/a/msys64/ucrt64/include"
ignoring nonexistent directory "/ucrt64/include"
ignoring duplicate directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.2.0/include-fixed"      
ignoring nonexistent directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "D:/a/msys64/ucrt64/include"
#include "..." search starts here:
#include <...> search starts here:
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/include
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../include
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/include-fixed
End of search list.
Compiler executable checksum: 9ededbb617523f3ae037d5140d325cc4
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=nocona' '-dumpdir' 'a-'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/as.exe -v -o C:\Users\MAX_LA~1\AppData\Local\Temp\ccL7LZeY.o C:\Users\MAX_LA~1\AppData\Local\Temp\ccZTHxVc.s
GNU assembler version 2.41 (x86_64-w64-mingw32) using BFD version (GNU Binutils) 2.41
COMPILER_PATH=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/;C:/msys64/ucrt64/bin/../lib/gcc/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/;C:/msys64/ucrt64/bin/../lib/gcc/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=nocona' '-dumpdir' 'a.'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/collect2.exe -plugin C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/liblto_plugin.dll -plugin-opt=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\MAX_LA~1\AppData\Local\Temp\ccJZh93P.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32 -m i386pep -Bdynamic C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib/crt2.o C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/crtbegin.o -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0 -LC:/msys64/ucrt64/bin/../lib/gcc -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../.. C:\Users\MAX_LA~1\AppData\Local\Temp\ccL7LZeY.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib/default-manifest.o C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/crtend.o
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\MAX_LA~1\AppData\Local\Temp\ccL7LZeY.o:Hellow world.c:(.text+0x13): undefined reference to `SetProcessDpiAwareness'     
collect2.exe: error: ld returned 1 exit status
PS D:\MaxLife\Programming\Learn\C>

@mati865
Copy link
Collaborator

mati865 commented Oct 17, 2024

idk why it tries to search in D:\
,even there isn't a there,

This directory was used on CI to build GCC, so it became hardcoded as a search path.


Regarding your error, it's an entirely different error from your previous comment. This one indicates missing -lshcore argument.
Your compiler is out of date, if issues persist you should try updating whole MSYS2.

@xmaxrayx
Copy link

Ok I found the issue :

winuser.h

there 2 files with same names but

  • winuser.h by mingw-w64 .
  • WinUser.h by Microsoft (one has capitalized).

winuser.h

C:\msys64\ucrt64\include\winuser.h
top file :

/**
 * This file is part of the mingw-w64 runtime package.
 * No warranty is given; refer to the file DISCLAIMER within this package.
 */


....some code

if a function used by that library it will do this (see the picture)
image

you see I actually have theses library on same folder (step 3)

WinUser.h

found here C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um\WinUser.h

top file

#include <winapifamily.h>

/****************************************************************************
*                                                                           *
* winuser.h -- USER procedure declarations, constant definitions and macros *
*                                                                           *
* Copyright (c) Microsoft Corporation. All rights reserved.                 *
*                                                                           *
****************************************************************************/

@xmaxrayx
Copy link

idk why it tries to search in D:
,even there isn't a there,

This directory was used on CI to build GCC, so it became hardcoded as a search path.

Regarding your error, it's an entirely different error from your previous comment. This one indicates missing -lshcore argument. Your compiler is out of date, if issues persist you should try updating whole MSYS2.

Ok many thanks , but how did you know that?

PS D:\MaxLife\Programming\Learn\C> gcc -v -lshcore  "Hellow world.c"
Using built-in specs.
COLLECT_GCC=C:\msys64\ucrt64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-13.2.0/configure --prefix=/ucrt64 --with-local-prefix=/ucrt64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/ucrt64/include --libexecdir=/ucrt64/lib --enable-bootstrap --enable-checking=release --with-arch=nocona --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-libssp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/ucrt64 --with-mpfr=/ucrt64 --with-mpc=/ucrt64 --with-isl=/ucrt64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Rev3, Built by MSYS2 project)
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=nocona' '-dumpdir' 'a-'
 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/cc1.exe -quiet -v -iprefix C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/ -D_REENTRANT Hellow world.c -quiet -dumpdir a- -dumpbase Hellow world.c -dumpbase-ext .c -mtune=generic -march=nocona -version -o C:\Users\MAX_LA~1\AppData\Local\Temp\ccj2KkKj.s
GNU C17 (Rev3, Built by MSYS2 project) version 13.2.0 (x86_64-w64-mingw32)
        compiled by GNU C version 13.2.0, GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version isl-0.26-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/include"
ignoring duplicate directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.2.0/include"
ignoring nonexistent directory "D:/a/msys64/ucrt64/include"
ignoring nonexistent directory "/ucrt64/include"
ignoring duplicate directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.2.0/include-fixed"
ignoring nonexistent directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "D:/a/msys64/ucrt64/include"
#include "..." search starts here:
#include <...> search starts here:
 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/include
 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../include
 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/include-fixed
End of search list.
Compiler executable checksum: 9ededbb617523f3ae037d5140d325cc4
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=nocona' '-dumpdir' 'a-'
 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/as.exe -v -o C:\Users\MAX_LA~1\AppData\Local\Temp\cc0lPVF4.o C:\Users\MAX_LA~1\AppData\Local\Temp\ccj2KkKj.s
GNU assembler version 2.41 (x86_64-w64-mingw32) using BFD version (GNU Binutils) 2.41
COMPILER_PATH=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/;C:/msys64/ucrt64/bin/../lib/gcc/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/;C:/msys64/ucrt64/bin/../lib/gcc/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=nocona' '-dumpdir' 'a.'
 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/collect2.exe -plugin C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/liblto_plugin.dll -plugin-opt=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\MAX_LA~1\AppData\Local\Temp\ccxEf93U.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32 -m i386pep -Bdynamic C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib/crt2.o C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/crtbegin.o -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0 -LC:/msys64/ucrt64/bin/../lib/gcc -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../.. -lshcore C:\Users\MAX_LA~1\AppData\Local\Temp\cc0lPVF4.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib/default-manifest.o C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/crtend.o
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\MAX_LA~1\AppData\Local\Temp\cc0lPVF4.o:Hellow world.c:(.text+0x13): undefined reference to `SetProcessDpiAwareness'
collect2.exe: error: ld returned 1 exit status
PS D:\MaxLife\Programming\Learn\C> gcc -v -lshcore  "Hellow world.c"
Using built-in specs.
COLLECT_GCC=C:\msys64\ucrt64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/lto-wrapper.exe      
Target: x86_64-w64-mingw32
Configured with: ../gcc-13.2.0/configure --prefix=/ucrt64 --with-local-prefix=/ucrt64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/ucrt64/include --libexecdir=/ucrt64/lib --enable-bootstrap --enable-checking=release --with-arch=nocona --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-libssp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/ucrt64 --with-mpfr=/ucrt64 --with-mpc=/ucrt64 --with-isl=/ucrt64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Rev3, Built by MSYS2 project)
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=nocona' '-dumpdir' 'a-'
 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/cc1.exe -quiet -v -iprefix C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/ -D_REENTRANT Hellow world.c -quiet -dumpdir a- -dumpbase Hellow world.c -dumpbase-ext .c -mtune=generic -march=nocona -version -o C:\Users\MAX_LA~1\AppData\Local\Temp\ccVz6oiA.s
GNU C17 (Rev3, Built by MSYS2 project) version 13.2.0 (x86_64-w64-mingw32)
        compiled by GNU C version 13.2.0, GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version isl-0.26-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/include"
ignoring duplicate directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.2.0/include"
ignoring nonexistent directory "D:/a/msys64/ucrt64/include"
ignoring nonexistent directory "/ucrt64/include"
ignoring duplicate directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.2.0/include-fixed"
ignoring nonexistent directory "C:/msys64/ucrt64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "D:/a/msys64/ucrt64/include"
#include "..." search starts here:
#include <...> search starts here:
 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/include
 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../include
 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/include-fixed
End of search list.
Compiler executable checksum: 9ededbb617523f3ae037d5140d325cc4
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=nocona' '-dumpdir' 'a-'
 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/as.exe -v -o C:\Users\MAX_LA~1\AppData\Local\Temp\ccoiHn1E.o C:\Users\MAX_LA~1\AppData\Local\Temp\ccVz6oiA.s
GNU assembler version 2.41 (x86_64-w64-mingw32) using BFD version (GNU Binutils) 2.41
COMPILER_PATH=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/;C:/msys64/ucrt64/bin/../lib/gcc/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/;C:/msys64/ucrt64/bin/../lib/gcc/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib/;C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=nocona' '-dumpdir' 'a.'
 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/collect2.exe -plugin C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/liblto_plugin.dll -plugin-opt=C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\MAX_LA~1\AppData\Local\Temp\ccxk9ThP.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32 -m i386pep -Bdynamic C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib/crt2.o C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/crtbegin.o -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0 -LC:/msys64/ucrt64/bin/../lib/gcc -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib -LC:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../.. -lshcore C:\Users\MAX_LA~1\AppData\Local\Temp\ccoiHn1E.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib/default-manifest.o C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/crtend.o
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\MAX_LA~1\AppData\Local\Temp\ccoiHn1E.o:Hellow world.c:(.text+0x13): undefined reference to `SetProcessDpiAwareness'
collect2.exe: error: ld returned 1 exit status
PS D:\MaxLife\Programming\Learn\C> 

changed code

will I replaced SetProcessDpiAwareness() to SetProcessDPIAware() (librray by MS) and everything works fine idk why.
is this licenses thing by MS?

#include <windows.h>
//#include <shellscalingapi.h>
//#include <WinUser.h>
#include <stdio.h>


//#pragma comment(lib, "user32.lib")

int main() {
    // Set the process to be DPI aware
    // SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
    SetProcessDPIAware();
    char name[] = "Max";
    MessageBoxA(0, name, "AAA", 1);
    ShellMessageBoxA(0, 0, "ssss", "hhh", 0);
    printf("%s", name);




    return 0;
}

@mati865
Copy link
Collaborator

mati865 commented Oct 17, 2024

Ok I found the issue :

This is an issue with your VS Code setup, not the compiler.

Ok many thanks , but how did you know that?

Because of undefined reference to `SetProcessDpiAwareness'. If you search for this function on the web, you can see it's part of Shcore.dll.

will I replaced SetProcessDpiAwareness() to SetProcessDPIAware() (librray by MS) and everything works fine idk why.

SetProcessDPIAware is part of User32.dll which is implicitly linked (look for -luser32 in gcc -v output).

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

No branches or pull requests