title: Access denied running program in Visual Studio
body: <p>so far I have only used Linux to write C++ code, but I want to learn to do it in Windows as well using CMake to simplify things.</p>
  
  <p>To get started, I have written the following CMakeLists.txt:</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8)  
  PROJECT( CMakeWin )
  
  SET(CMAKE_BUILD_TYPE Release)
  
  # find opencv and set variables
  Set(OpenCV_DIR C:/Users/Erik/Documents/Libraries/opencv/build)
  FIND_PACKAGE(OpenCV REQUIRED)
  
  
  #set the default path for built executables to the "bin" directory
  set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
  
  ADD_EXECUTABLE( ${PROJECT_NAME}
  src/main.cpp 
  )
  
  
  TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${OpenCV_LIBS})
  </code></pre>
  
  <p>When I run CMake (using Visual Studio 11 configuration) it seems to work properly, but when I open the CMakeWin.sln project and build and then run it, I get </p>
  
  <pre><code>Unable to start program C:\..... The system cannot find the file 
  specified.
  </code></pre>
  
  <p>But I have also received </p>
  
  <pre><code>access denied.
  </code></pre>
  
  <p>When I go directly to the Release or Debug folder and run </p>
  
  <pre><code>CMakeWin.exe
  </code></pre>
  
  <p>it runs as it shall. What can the problem be?</p>
  
  <p>EDIT:</p>
  
  <p>To avoid making visual studio trying to run ALL_BUILD, I had to set CMakeWin as the StartUp project. See <a href="https://simtk.org/forums/viewtopic.php?f=91&amp;t=3676" rel="noreferrer">https://simtk.org/forums/viewtopic.php?f=91&amp;t=3676</a> and comments below.</p>