CMake / Meson run check DLL Hell
CMake
check_source_runs
and Meson
compiler.run
check if source code compiles, links, and runs correctly.
If the checked program uses shared libraries (DLLs) such as libstdc++ on Windows, the program may fail to run due to conflicting DLLs in the Path environment variable.
In
CMakeConfigureLog.yaml
or meson-logs/meson-log.txt,
the error code may be
0xc0000139 STATUS_ENTRYPOINT_NOT_FOUND
or 3221225785
corresponding to a conflicting DLL.
Error code
0xc0000135 STATUS_DLL_NOT_FOUND
corresponds to a missing DLL.
The general solution is to avoid unnecessary paths in the Path environment variable. Ensure the compiler and runtime library path are in the Path environment variable before conflicting DLL paths. Check if libstdc++ has multiple entries in the Path, particularly before the compiler and runtime libraries DLL directory. From Terminal:
where.exe libstdc++*.dll
If this prints
INFO: Could not find files for the given pattern(s).
then the libstdc++ DLL is not in the Path, which may result in error code 0xc0000135. If the libstdc++ DLL is in the Path, check if it is in multiple locations. The ideal is to have one path result. At least the desired compiler/library path must be the first result.
For example, Meld is a program that causes DLL conflicts if put on the Path.
Examples of using small PowerShell scripts for GCC and Clang.