- Remove From My Forums
-
Вопрос
-
Только начал обучение С++ по учебнику Страуструпа.
Загрузил Visual StudioНачал со стандартного «Hello, World!»
Отладка проходит успешно, ошибок нет.
Однако программа не запускается.
Выходят следующие сообщения:
Следующий проект устарел: Hello, World — Debug Win32
Не удается запустить программу: …/HelloWorld.exe
Не удается найти указанный файлЧто я делаю не так?
Система: Wind x64.
Ответы
-
Книга нашего дорогого и горячо любимого Страуструпа написана о языке программирования, а не о работе в среде разработки Visual Studio. Последнее описано в справочной системе (в крайнем случае, есть сайт msdn.microsoft.com/library).
Советую там ознакомиться с технологией создания проекта VC++ и процедурой преобразования исходного кода в исполняемый модуль.-
Изменено
20 ноября 2013 г. 5:37
-
Помечено в качестве ответа
Maksim MarinovMicrosoft contingent staff, Moderator
2 декабря 2013 г. 7:42
-
Изменено
I installed Visual Studio 2010. I wrote a simple code which I’m sure is correct but unfortunately, when I run the code, I get the error below.
Here is my code:
#include<iostream>
using namespace std;
int main (){
cout <<"Hello StackOverFlow ;)";
return 0;
}
And here is the error:
Unable to start program ‘C:UsersSoheilDesktopNew foldersamDebugsam.exe
The system cannot find the file specified
Would you help me solve the issue? Should I define the project in a
specific directory? I’ve spent a ton of hours to solve this issue and
have not had any success yet.
pmr
57.7k10 gold badges110 silver badges155 bronze badges
asked May 12, 2013 at 20:51
21
This is a first step for somebody that is a beginner. Same thing happened to me:
Look in the Solution Explorer box to the left. Make sure that there is actually a .cpp file there. You can do the same by looking the .cpp file where the .sln file for the project is stored. If there is not one, then you will get that error.
When adding a cpp file you want to use the Add new item icon. (top left with a gold star on it, hover over it to see the name) For some reason Ctrl+N does not actually add a .cpp file to the project.
![]()
answered Nov 9, 2013 at 17:44
cdelsolacdelsola
3972 gold badges7 silver badges17 bronze badges
1
Encountered the same issue, after downloading a project, in debug mode. Searched for hours without any luck. Following resolved my problem;
Project Properties -> Linker -> Output file -> $(OutDir)$(TargetName)$(TargetExt)
It was previously pointing to a folder that MSVS wasn’t running from whilst debugging mode.
EDIT: soon as I posted this I came across: unable to start «program.exe» the system cannot find the file specified vs2008 which explains the same thing.
answered Mar 20, 2016 at 5:51
ReturnVoidReturnVoid
1,0711 gold badge10 silver badges17 bronze badges
0
I know this is an old thread, but for any future visitors, the cause of this error is most likely because you haven’t built your project from Build > Build Solution. The reason you’re getting this error when you try to run your project is because Visual Studio can’t find the executable file that should be produced when you build your project.
answered Oct 31, 2015 at 16:14
![]()
Ethan BierleinEthan Bierlein
3,2534 gold badges27 silver badges41 bronze badges
1
As others have mentioned, this is an old thread and even with this thread there tends to be different solutions that worked for different people. The solution that worked for is as follows:
Right Click Project Name > Properties
Linker > General
Output File > $(OutDir)$(TargetName)$(TargetExt) as indicated by @ReturnVoid
Click Apply
For whatever reason this initial correction didn’t fix my problem (I’m using VS2015 Community to build c++ program). If you still get the error message try the following additional steps:
Back in Project > Properties > Linker > General > Output File >
You’ll see the previously entered text in bold
Select Drop Down > Select "inherit from parent or project defaults"
Select Apply
Previously bold font is no longer bold
Build > Rebuild > Debug
It doesn’t make since to me to require these additional steps in addition to what @ReturnVoid posted but…what works is what works…hope it helps someone else out too. Thanks @ReturnVoid
answered Apr 9, 2016 at 22:24
![]()
ChrisChris
9241 gold badge16 silver badges37 bronze badges
1
I came across this problem and none of these solution worked 100%
In addition to ReturnVoid’s answer which suggested the change
Project Properties -> Linker -> Output file -> $(OutDir)$(TargetName)$(TargetExt)
I needed to changed
Project Properties -> C/C++ -> Debug Information Format ->
/Zi
This field was blank for me, changing the contents to /Zi (or /Z7 or /ZI if those are the formats you want to use) allowed me to debug
answered Jan 9, 2019 at 15:58
rtpaxrtpax
1,64716 silver badges31 bronze badges
For me, I didn’t have my startup project set in Solution Explorer.
Go to Solution Explorer on the left of VS, right click your unit test project, and choose «set as startup project».
I had just ported my code to a new workspace, and forgot that when I opened the project in VS in the solution there, that I needed to re-set my startup project.
answered Apr 11, 2017 at 15:35
![]()
MicheleMichele
3,42411 gold badges44 silver badges79 bronze badges
I know this thread is 1 year old but I hope this helps someone, my problem was that I needed to add:
#include "stdafx.h"
to my project (on the first line), this seems to be the case most of the time!
answered May 28, 2014 at 0:25
Windows65Windows65
571 silver badge7 bronze badges
2
I got this problem during debug mode and the missing file was from a static library I was using. The problem was solved by using step over instead of step into during debugging
answered Apr 26, 2019 at 0:25
![]()
mistymisty
111 silver badge4 bronze badges
if vs2010 installed correctly
check file type (.cpp)
just build it again It will automatically fix,, ( if you are using VS 2010 )
answered Aug 12, 2014 at 12:35
ANJiANJi
278 bronze badges
I had a same problem and i could fixed it!
you should add
C:Program Files (x86)Microsoft SDKsWindowsv7.1ALibx64 for 64 bit system
/ C:Program Files (x86)Microsoft SDKsWindowsv7.1ALib for 32 bit system
in property manager-> Linker-> General->Additional library Directories
maybe it can solve the problem of somebody in the future!
answered Sep 6, 2014 at 15:26
I installed Visual Studio 2010. I wrote a simple code which I’m sure is correct but unfortunately, when I run the code, I get the error below.
Here is my code:
#include<iostream>
using namespace std;
int main (){
cout <<"Hello StackOverFlow ;)";
return 0;
}
And here is the error:
Unable to start program ‘C:UsersSoheilDesktopNew foldersamDebugsam.exe
The system cannot find the file specified
Would you help me solve the issue? Should I define the project in a
specific directory? I’ve spent a ton of hours to solve this issue and
have not had any success yet.
pmr
57.7k10 gold badges110 silver badges155 bronze badges
asked May 12, 2013 at 20:51
21
This is a first step for somebody that is a beginner. Same thing happened to me:
Look in the Solution Explorer box to the left. Make sure that there is actually a .cpp file there. You can do the same by looking the .cpp file where the .sln file for the project is stored. If there is not one, then you will get that error.
When adding a cpp file you want to use the Add new item icon. (top left with a gold star on it, hover over it to see the name) For some reason Ctrl+N does not actually add a .cpp file to the project.
![]()
answered Nov 9, 2013 at 17:44
cdelsolacdelsola
3972 gold badges7 silver badges17 bronze badges
1
Encountered the same issue, after downloading a project, in debug mode. Searched for hours without any luck. Following resolved my problem;
Project Properties -> Linker -> Output file -> $(OutDir)$(TargetName)$(TargetExt)
It was previously pointing to a folder that MSVS wasn’t running from whilst debugging mode.
EDIT: soon as I posted this I came across: unable to start «program.exe» the system cannot find the file specified vs2008 which explains the same thing.
answered Mar 20, 2016 at 5:51
ReturnVoidReturnVoid
1,0711 gold badge10 silver badges17 bronze badges
0
I know this is an old thread, but for any future visitors, the cause of this error is most likely because you haven’t built your project from Build > Build Solution. The reason you’re getting this error when you try to run your project is because Visual Studio can’t find the executable file that should be produced when you build your project.
answered Oct 31, 2015 at 16:14
![]()
Ethan BierleinEthan Bierlein
3,2534 gold badges27 silver badges41 bronze badges
1
As others have mentioned, this is an old thread and even with this thread there tends to be different solutions that worked for different people. The solution that worked for is as follows:
Right Click Project Name > Properties
Linker > General
Output File > $(OutDir)$(TargetName)$(TargetExt) as indicated by @ReturnVoid
Click Apply
For whatever reason this initial correction didn’t fix my problem (I’m using VS2015 Community to build c++ program). If you still get the error message try the following additional steps:
Back in Project > Properties > Linker > General > Output File >
You’ll see the previously entered text in bold
Select Drop Down > Select "inherit from parent or project defaults"
Select Apply
Previously bold font is no longer bold
Build > Rebuild > Debug
It doesn’t make since to me to require these additional steps in addition to what @ReturnVoid posted but…what works is what works…hope it helps someone else out too. Thanks @ReturnVoid
answered Apr 9, 2016 at 22:24
![]()
ChrisChris
9241 gold badge16 silver badges37 bronze badges
1
I came across this problem and none of these solution worked 100%
In addition to ReturnVoid’s answer which suggested the change
Project Properties -> Linker -> Output file -> $(OutDir)$(TargetName)$(TargetExt)
I needed to changed
Project Properties -> C/C++ -> Debug Information Format ->
/Zi
This field was blank for me, changing the contents to /Zi (or /Z7 or /ZI if those are the formats you want to use) allowed me to debug
answered Jan 9, 2019 at 15:58
rtpaxrtpax
1,64716 silver badges31 bronze badges
For me, I didn’t have my startup project set in Solution Explorer.
Go to Solution Explorer on the left of VS, right click your unit test project, and choose «set as startup project».
I had just ported my code to a new workspace, and forgot that when I opened the project in VS in the solution there, that I needed to re-set my startup project.
answered Apr 11, 2017 at 15:35
![]()
MicheleMichele
3,42411 gold badges44 silver badges79 bronze badges
I know this thread is 1 year old but I hope this helps someone, my problem was that I needed to add:
#include "stdafx.h"
to my project (on the first line), this seems to be the case most of the time!
answered May 28, 2014 at 0:25
Windows65Windows65
571 silver badge7 bronze badges
2
I got this problem during debug mode and the missing file was from a static library I was using. The problem was solved by using step over instead of step into during debugging
answered Apr 26, 2019 at 0:25
![]()
mistymisty
111 silver badge4 bronze badges
if vs2010 installed correctly
check file type (.cpp)
just build it again It will automatically fix,, ( if you are using VS 2010 )
answered Aug 12, 2014 at 12:35
ANJiANJi
278 bronze badges
I had a same problem and i could fixed it!
you should add
C:Program Files (x86)Microsoft SDKsWindowsv7.1ALibx64 for 64 bit system
/ C:Program Files (x86)Microsoft SDKsWindowsv7.1ALib for 32 bit system
in property manager-> Linker-> General->Additional library Directories
maybe it can solve the problem of somebody in the future!
answered Sep 6, 2014 at 15:26
I have a solution in C:full path hereVS2010blender.sln
This solution contains many projects(around 100). When I compile them, they all work fine. I can run them without any problem, and (quite) everything works (there are some bugs).
One of the projects is ALL_BUILD, but it gives the same error if I try to debug INSTALL(another project). I’m compiling with RELWithDebInfo as configuration, and if I execute the program manually it works. It is outputted in C:full path hereVS2010binRelWithDebInfo
But if I try to run the compiler, it says
«Unable to start program
C:full path hereVS2010RelWithDebInfoALL_BUILD
Specified file cannot be found»
I tried to copy the compiled program into the path required by VS, but it raised the same error.
What should I do to solve this? Right now I set up cmake to generate also a mingw project and I compile it and debug it with gdb, but this is a really a slow and impractical workflow, and I would like to use the VS debugger.
I must say that if I compile with Debug as configuration, the program doesn’t even start.
I’m using VS2010 Express on Win7 64bit
(This is a big open source program, so I don’t know exactly whatever it does)
I have a solution in C:full path hereVS2010blender.sln
This solution contains many projects(around 100). When I compile them, they all work fine. I can run them without any problem, and (quite) everything works (there are some bugs).
One of the projects is ALL_BUILD, but it gives the same error if I try to debug INSTALL(another project). I’m compiling with RELWithDebInfo as configuration, and if I execute the program manually it works. It is outputted in C:full path hereVS2010binRelWithDebInfo
But if I try to run the compiler, it says
«Unable to start program
C:full path hereVS2010RelWithDebInfoALL_BUILD
Specified file cannot be found»
I tried to copy the compiled program into the path required by VS, but it raised the same error.
What should I do to solve this? Right now I set up cmake to generate also a mingw project and I compile it and debug it with gdb, but this is a really a slow and impractical workflow, and I would like to use the VS debugger.
I must say that if I compile with Debug as configuration, the program doesn’t even start.
I’m using VS2010 Express on Win7 64bit
(This is a big open source program, so I don’t know exactly whatever it does)
|
19 / 19 / 6 Регистрация: 22.03.2011 Сообщений: 84 |
|
|
1 |
|
«Не удаётся найти указанный файл» после запуска программы22.03.2011, 16:26. Показов 154768. Ответов 35
в Microsoft Visual Studio 2008 при попытке запуска программы выходит сообщение «Не удаётся запустить программу» дальше путь к файлу вернее где он должен быть и дальше «Не удаётся найти указанный файл»
__________________
0 |
|
Brainsbreaker 896 / 372 / 52 Регистрация: 01.02.2011 Сообщений: 1,592 |
|
|
22.03.2011, 19:27 |
2 |
|
Поподробней, можно со скрином…
0 |
|
Делаю внезапно и красиво
1312 / 1227 / 72 Регистрация: 22.03.2011 Сообщений: 3,744 |
|
|
22.03.2011, 19:43 |
3 |
|
Раз файла нет, то он не был скомпонован. Или рабочая директория отличается от той, в которую файл собирался.
0 |
|
374 / 321 / 32 Регистрация: 24.02.2011 Сообщений: 1,512 Записей в блоге: 1 |
|
|
22.03.2011, 20:29 |
4 |
|
Проект то компилируется нормально? Если нет, то что говорит?
0 |
|
19 / 19 / 6 Регистрация: 22.03.2011 Сообщений: 84 |
|
|
24.03.2011, 18:54 [ТС] |
5 |
|
Сначало создаю пустой проект С++ затем создаю файл С++ , пишу программу нажимаю F5 дальше появляется окно которое рис 1 нажимаю «да» и появлется ошибка рис 2
0 |
|
Делаю внезапно и красиво
1312 / 1227 / 72 Регистрация: 22.03.2011 Сообщений: 3,744 |
|
|
24.03.2011, 19:11 |
6 |
|
Нажми Ф7, а не Ф5.
0 |
|
374 / 321 / 32 Регистрация: 24.02.2011 Сообщений: 1,512 Записей в блоге: 1 |
|
|
24.03.2011, 19:12 |
7 |
|
Не по теме: А что, картинку к сообщению прикрепить не судьба Вы не F5 нажимайте, а если проект в решении один, то F7. Или правой кнопкой по названию проекта в Обозревателе решения и Построение. В окне Вывода (внизу) будут перечислены ошибки. Выделите все, скопируйте и сюда. Да и код тоже.
0 |
|
Делаю внезапно и красиво
1312 / 1227 / 72 Регистрация: 22.03.2011 Сообщений: 3,744 |
|
|
24.03.2011, 19:19 |
8 |
|
F7 — компиляция
0 |
|
Антон555 19 / 19 / 6 Регистрация: 22.03.2011 Сообщений: 84 |
||||
|
24.03.2011, 19:28 [ТС] |
9 |
|||
то что внизу 1>Внедрение манифеста…
0 |
|
Делаю внезапно и красиво
1312 / 1227 / 72 Регистрация: 22.03.2011 Сообщений: 3,744 |
|
|
24.03.2011, 19:33 |
10 |
|
5 — ошибок Добавлено через 28 секунд
0 |
|
19 / 19 / 6 Регистрация: 22.03.2011 Сообщений: 84 |
|
|
24.03.2011, 19:38 [ТС] |
11 |
|
вопрос в том, что так происходит при любом коде, перепробывал много исходников… может какие то настройки виноваты..
0 |
|
Делаю внезапно и красиво
1312 / 1227 / 72 Регистрация: 22.03.2011 Сообщений: 3,744 |
|
|
24.03.2011, 19:40 |
12 |
|
Манифест создан? Раз это последняя вменяемая строка, возможно на его внедрении и падает.
1 |
|
19 / 19 / 6 Регистрация: 22.03.2011 Сообщений: 84 |
|
|
24.03.2011, 19:45 [ТС] |
13 |
|
Всё получилось, спасибо.
0 |
|
bigredcat 374 / 321 / 32 Регистрация: 24.02.2011 Сообщений: 1,512 Записей в блоге: 1 |
||||
|
24.03.2011, 19:46 |
14 |
|||
|
Вы один фиг F5 нажимаете.
0 |
|
19 / 19 / 6 Регистрация: 22.03.2011 Сообщений: 84 |
|
|
24.03.2011, 19:47 [ТС] |
15 |
|
Спасибо, всё получилось. А что за манифест? (извеняюсь если вопрос очень глупый)=)
0 |
|
Dmitrii9999 |
|
|
27.04.2011, 12:38 |
16 |
|
Антон555, так как ты решил проблему,а то у меня тоже такая |
|
0 / 0 / 0 Регистрация: 05.09.2014 Сообщений: 3 |
|
|
27.10.2011, 18:25 |
17 |
|
у мене тоже похожая ошибка токо после того как я нажимаю Ф7 у меня сразу начинает перезагружатся программа
0 |
|
2 / 2 / 0 Регистрация: 02.02.2012 Сообщений: 35 |
|
|
09.11.2012, 17:37 |
18 |
|
Как проблему то решили?
0 |
|
6 / 6 / 5 Регистрация: 22.11.2012 Сообщений: 95 |
|
|
03.12.2012, 23:04 |
19 |
|
ну вот а ответа как решить проблему нема((( ужас то какой та же самая проблема
0 |
|
Nirvanovec 25 / 31 / 22 Регистрация: 25.01.2010 Сообщений: 322 Записей в блоге: 1 |
||||
|
23.12.2012, 11:35 |
20 |
|||
|
[cut] Добавлено через 4 минуты
0 |
|
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
23.12.2012, 11:35 |
|
20 |
При отладке программы, если вы получаете Невозможно запустить программу, Доступ запрещен ошибка, вот как вы можете избавиться от проблемы. Эта ошибка может возникать в Visual Studio 2019, а также Visual Studio 2022. Если вы получите эту проблему на Windows 11, Windows 10, или любые другие более старые версии, вы можете воспользоваться этими решениями для устранения проблемы.

Чтобы исправить ошибку «Невозможно запустить программу, доступ запрещен» в Visual Studio, выполните следующие действия:
- Проверьте с учетной записью администратора
- Выберите правильный файл для компиляции
- Запустить установщик с другого диска
- Отключить сторонний брандмауэр и антивирус
- Сбросить Visual Studio
Чтобы узнать больше об этих шагах, продолжайте читать.
1] Проверьте с учетной записью администратора
Иногда вам может понадобиться использовать учетную запись администратора для запуска проекта в Visual Studio в Windows 11 или Windows 10 ПК. Независимо от того, какой язык вы использовали, вам нужно выбрать учетную запись администратора, чтобы избавиться от этой проблемы. Если вы сейчас используете стандартную учетную запись, вам необходимо выйти из этой учетной записи и начать использовать учетную запись администратора.
Существует два основных способа создания учетной записи администратора в Windows 11/10 шт. Вы можете включить скрытую учетную запись администратора or создать локальную учетную запись администратора. Вы можете следовать любому методу, чтобы выполнить работу. Вслед за этим вам необходимо войдите как администратор для устранения проблемы.
2] Выберите правильный файл для компиляции
В большинстве случаев пользователи забывают выбрать правильный файл проекта для компиляции. В результате они сталкиваются с такой проблемой при отладке в Visual Studio. Если вы работали над одним проектом раньше, а потом переключились на другой, это может быть распространенной ошибкой. Вот почему настоятельно рекомендуется проверить правильный файл проекта перед повторной попыткой.
3] Запустите установщик с другого диска
Если вы установили Visual Studio на другом диске, отличном от системного или диска C, вам нужно запустить программу установки только с этого диска. Время от времени ваш компьютер может не делать все, когда вы устанавливаете программу на другой диск. Хотя это не должно быть проблемой, поскольку Windows может запускать программы с любого диска, Visual Studio может вызвать у вас проблемы по этой причине. Вот почему вы можете следовать этому пошаговому руководству, чтобы переместить установленные программы на другой диск без потери данных in Windows 11 / 10.
4] Отключите сторонний брандмауэр и антивирус
Windows Безопасность не создает проблем с Visual Studio, поскольку они очень совместимы друг с другом. Однако, если вы используете сторонний брандмауэр или антивирусную программу на своем компьютере, вы можете столкнуться с этой проблемой. Вот почему рекомендуется временно отключить брандмауэр и антивирусную программу, чтобы проверить, решает ли это проблему или нет.
Если да, вы можете попробовать сбросить эти программы и проверить еще раз. Если это не решит проблему, вам нужно избавиться от этих приложений, чтобы использовать Visual Studio без каких-либо ошибок.
Похожие страницы:: Visual Studio, Невозможно запустить программу, Системе не удается найти указанный файл
5] Сбросить Visual Studio
Чтобы сбросить Visual Studio в Windows 11/10 выполните следующие действия:
- Откройте Visual Studio на своем компьютере.
- Нажмите на Инструменты меню.
- Выберите Импорт и экспорт Вариант настроек.
- Выберите Сбросить все настройки опцию.
- Нажмите Далее кнопку.
- Выберите Да, сохранить мои текущие настройки возможность сохранить текущую настройку.
- Выберите Нет, просто сбросить настройки возможность сбросить все.
- Нажмите Далее кнопку.
- Нажмите на Завершить кнопку.
После этого проверьте, есть ли проблема или нет.
Читайте: Установщик Visual Studio зависает при загрузке
Как исправить отказ в доступе в Visual Studio?
Для того, чтобы исправить Доступ запрещен ошибка в Visual Studio, вам необходимо воспользоваться вышеупомянутыми решениями. Во-первых, проверьте, есть ли у вас учетная запись администратора или нет. После этого не забудьте проверить настройки брандмауэра и антивируса. С другой стороны, вам может потребоваться восстановить настройки в Windows Реестр, чтобы избавиться от этой проблемы.
Как запустить Visual Studio от имени администратора?
Чтобы запустить Visual Studio от имени администратора в Windows 11 или Windows 10, вы можете использовать меню «Пуск». Тем не менее, нажмите на меню «Пуск» и найдите визуальная студия. Увидев результат поиска, убедитесь, что выбрана Visual Studio. Если это так, нажмите на Запуск от имени администратора и нажмите Да в командной строке UAC.
Оригинал статьи