Author Topic: Code::Blocks + CygWin + Path Variable + DLL Clobber + Win32  (Read 6596 times)

Offline Raijinsetsu

  • Multiple posting newcomer
  • *
  • Posts: 16
Ok... To use CygWin with Code::Blocks, you need to change your Path variable, right? Example: Path=%Path%;C:\CygWin\bin;C:\CygWin\usr\bin.
The problem I've found with this is: CygWin has libraries that clobber the other programs that use the GTK(Gaim, Gimp, etc.). If you don't change your path, C::B won't start, says it can't find mingw.dll(at least on my system). Copying the DLL to multiple directories makes upgrading, and maintaining, a pain.
My solution: use windows scripting
File: \Program Files\CodeBlocks\codeblocks.js
var shell=WScript.CreateObject("WScript.Shell");

var penv=shell.Environment("PROCESS");
var senv=shell.Environment("SYSTEM");

penv("PATH") = senv("PATH") + ";C:\\cygwin\\bin;C:\\cygwin\\usr\\bin";

shell.Run("codeblocks.exe");


This script will set the path variable just for C::B to include the cygwin directory. It imports your systems Path also. This could also be used in conjunction with MinGW.


Offline Raijinsetsu

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Code::Blocks + CygWin + Path Variable + DLL Clobber + Win32
« Reply #2 on: July 15, 2006, 06:10:27 am »
I already fixed my problem. The problem with C::B was : without cygwin\bin and cygwin\usr\bin defined in the windows system path variable, C::B would not START, reporting that "mingw.dll" was missing. This is because this DLL is in cygwin\bin. Adding these paths to the system path variable fixes C::B, but breaks Aston-Shell, Gaim, and Gimp. This is because cygwin\bin and cygwin\usr\bin contain DLLs that clobber private DLLs belonging to the affore-mentioned programs(they have DLLs with the same name in their working directory, but they end up loading the ones in CygWin -- very bad). That's why I made the above script: to change the path variable just for C::B and any of it's child processes. Also, it appears that several windows programs had their DLLs clobbered in this fashion because my system stability had dropped since changing the path variable to include cygwin's bin directories.
In conclusion: most people should not edit the windows system variable to include the CygWin or MinGW paths because of the potential to clobber native DLLs.