Skip to main content Help Control Panel

Rod Morison Software —  Technotes

Home «   R&D «   C++ «   CxxTest setup for the Visual Studio IDE «  

Comment: C++

<< Previous Next >>

by Gail on Sep. 20 2008

I finally resolved the issues I had when trying to call runner.exe within the Visual Studio 2003 environment using a Post-Build Event. No output would show in the Build window (runner.exe was built using --runner=ParenPrinter).

The problem arose because my runner.exe depends on some external DLLs. The WINDOWS DLL runtime search order is: the parent directory of the executable, some system directories, and then the directories listed in %PATH%. I did not realize that Visual Studio does NOT use environment variables, like %PATH%, added or modified after VS has been installed!!!! It should be noted however that when running your program in the Debugger from within the IDE, it DOES use updates to the environment in place when the IDE is started. Even if you start devenv.exe from a shell, as opposed to a shortcut, the Post-Build event has no knowledge of changes to your environment that were made after installation. Only the geniuses at Microsoft can explain this behavior.

What this means is that external DLLs that are needed to run your test, and which you added to your PATH variable, are not available when the Post-Build event executes.

There are 2 solutions. The better option is to add the necessary env vars and update the path in a batch file that calls runner.exe. For example, place the following in a postbuild.cmd file located with your source code and call it in the Post-Build event:

set QTDIR=c:\someplace\qt\WINDOWS path = %PATH%;%QTDIR%\debug\lib runner.exe

The other solution is to add an entry to the VS Tools->Options->Projects->C++ Directories dialog when the the "Show Directories for:" dialog says "Executable Files". To match the above batch script, the entry would be c:\someplace\qt\WINDOWS\debug\lib.

I prefer the former since what is going on visible and explicit instead of being hidden in one of the dozens of dialogs in the IDE.