Menu

#1534 Running compiled program fails because of wrong PATH

Undefined
open
nobody
None
Undefined
2025-05-31
2025-05-31
No

My CB 20.03 on windows has two compilers installed and registered: The default MinGW 8.1 (still set as default compiler) and the new MinGW 14.2 from CodeBlocks 25.03 (selected in the project settings of some projects).

When I compile a C++ project with the new MinGW, the build is successful. But when I click the "Run" button, a Windows popup tells me that starting the program failed due to dll problems.

I tried to analyze the problem:
- The .exe file is linked against the runtime libs of the new MinGW.
- The gcc/stdc++ runtime lib's of both MinGW versions seem to have the same names.
- In the PATH which is implicitely set by CB for the CMD window in which the compiled program is started by "Run", the /bin directory of the old (default) MinGW preceedes the /bin directory of the MinGW used for compiling the program.
- So on program startup Windows seems to load the wrong (old) version of the gcc/stdc++ runtime dll's.

Starting the same .exe in a manually opened CMD windows with a manually set PATH works fine.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.