What happens is that VS adds the directories containing debug DLLs to PATH when starting the process to run under the debugger. The compiler isn't involved in this. The idea is that you run a debug build under control of the debugger (you can also run without debugging in VS.) If you want to run outside the VS environment, build a Release configuration (or choose non-debug libraries in the property for that.)