So I am trying to run console 64 bit Hello World program.
I have Windows 7 Enterprise x64 bit version.
I have installed Visual Studio 2008 and have added all of components needed for 64 bit.
I want to create simple console application.
It turns out to be a problem.
I have simple standard hello world project.
I have created it using New Project -> Empty project.
I added main.cpp that contains this:
#include <iostream>
using namespace std;
int main()
{
cout << "howdy\n";
}
I added new configuration to the project by clicking on Config Manager and added x64 config.
Compiled and it compiles.
Tried running it and cmd.exe shoots up with following error:
"The application has failed to start because its side-by-side configuration is in
correct. Please see the application event log or use the command-line sxstrace.e
xe tool for more detail.
Press any key to continue . . .
"
Which set-up step if any I am missing.
What am I doing wrong and how should I go about setting simple console hello world in 64 bit world.
Thanks for any help
Instead of starting with an Empty Project, choose a project of type "Console Application" in Visual Studio.
Related
I downloaded and run a C++ project for Digital-persona-sdk finger print. I run the environment in Visual Studio (Windows 10 64-bit). Compilation is done, but when I run the exe, this problem occurs:
Does anyone have an idea for solving this problem? Or, can you please give me any other sample project for working with the Digital persona fingerprint sdk in C++?
I find out the problem. It problem is my project has a window application. But i run the console application and select win32.
For the past hour I have been looking at multiple stack overflow questions trying including this one and this one trying to figure out why visual studio cannot open typical source files like stdio.h
I am starting out by building a new project and then selecting the "console app" option, but when I try to compile and run the simple hello world program I get the errors shown below.
Edit:
Here is the code that is generated by default when choosing the console application option in visual studio that I am trying to run:
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
The issue was that I thought I had the Widows 10 SDK installed, but apparently I did not. I found the answer using this stack overflow thread.
I had to download the Windows 10 SDK from here and restart the visual studio IDE and it worked straight away.
I have VS2017 installed on windows 10 machine and I am building my C++ code in it. when build success I am able to run that exe on same machine. But when I am copying that exe (with all dependent DLL's) on another winodws 10 machine where VS2017 is not installed its giving error "The code execution cannot proceed because urctbase.dll was not found".
I copied those dll's (ucrtbase.dll vcrutime140.dll etc.) at the same location where exe resides and try to run it then its giving error "The application was unable to start correctly(0xc700000b). Click OK to close the application"
I installed VC Redistributable-2017 package to setup run time environment on that machine, but problem persists.
Can anyone help to resolve this issue?
it's difficult to get all the dependent DLLs of your program. I suggest you create setup project that can detect all these dependencies:
0- Put your project in release mode
1- install Microsoft Visual Studio Installer Projects from here
2- Add setup project to your VS solution
3- Add your program to the setup project
4- Choose primary output of your project
5- As you can see, visual studio detect all dll dependencies
Just installed visual studio 2019 on windows 10, was using visual studio for the first time and ran into the following error, It's a basic hello world console program that I tried to run.
error C1083: Cannot open include file: 'corecrt.h': No such file or directory
1>Done building project "ConsoleApplication2.vcxproj" -- FAILED.
Severity Code Description Project File Line Suppression State
Warning MSB8003 The WindowsSDKDir property is not defined. Some build tools may not be found. ConsoleApplication2 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets 434
I tried searching for this error over YouTube and of course here, and also Microsoft's offical forum but couldn't find anything.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
}
the code looks just fine.
I ran into the same issue today. It turns out I didn't check the Win10SDK to save disk space while installation.
Solution:
In VS, go Tools menu=>Get Tools and Features=>install the Windows 10 SDK(10.XX.XX.XX)
Once installed, launch VS and open your project, right-click your project(NOT Solution)->properties->General->Windows SDK Version, check the value should be 10.0 instead of blank.
Then the compiling just worked.
I've got the same issue and turned out that I haven't installed Windows SDK. It can be done by typing "Install Windows SDK" into visual studio's search prompt
I had same problem when I installed Visual Studio 2019 on Windows7 and opened project created in Visual Studio 2017 (witch wasn't installed on that machine).
To solve the problem I went to project Properties -> General -> Windows SDK Version
And changed it from 10 to 8.1.
I fixed this issue by repairing Windows SDK. Now it's working as expected.
Steps:
Go to Settings>Apps & Features.
Click on Windows Software Development Kit - Windows 10.0.18362.1
(Note: Version number might be different for you)
Click on Modify.
Select Repair from options.
Click Next.
Restart VS and try running your project.
I was just having thesame issue so I figured maybe the headers were in a different directory than where the program is searching. When I went looking for tge header files none existed. So the problem is probably with iostream not existing.
I'm starting with an existing, monolithic, .exe native Visual Studio 2012 project. I want to add a native Unit Test project alongside, according to http://msdn.microsoft.com/en-us/library/hh419385.aspx#objectRef, which suggests that this is supported:
The code under test is built as an .exe file:
Add a separate test project. Link it to the output object file.
I dllexport'ed the methods I needed to test, linked my test project with the exe project's .lib library and things seemed to work for my simple test functions. However, as soon as I tried something more interesting I started getting access violations like this one:
First-chance exception at 0x04fa4aac (TestApplication.exe) in vstest.executionengine.x86.exe: 0xC0000005: Access violation reading location 0x011bf0e0.
So I created a new solution with the simplest .exe and Unity Test project pair I could muster and I was able to reproduce the exceptions with this caller (Unit Test project) and callee (.exe project):
Callee (.exe project) Header.h:
#include <string>
__declspec( dllexport ) std::string __cdecl strTest( std::string j );
Callee (.exe project) Header.cpp:
#include "Header.h"
std::string strTest( std::string j ) {
std::string output;
output += j;
output += "HAHA";
return output;
}
Caller (Unit Test project) unittest1.cpp:
#include "CppUnitTest.h"
#include "../TestApplication/Header.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTest {
TEST_CLASS(UnitTest1) {
public:
TEST_METHOD(TestMethod1) {
std::string test = strTest( "bla " );
}
};
}
The access violation always happens inside the std::string constructor being called by the std::string output; line in strTest().
I made sure that the two projects have identical settings (especially calling convention, optimization/debug settings, bit-ness, and character set). I also disabled and removed the pre-compiled headers for both projects.
I even tried creating a second exe project with the functions above and have my main exe project link against the second exe project. This worked perfectly. When I tried to have my Unit Test project link against that second exe project, in the same way I had my main exe project working, I got the same access violations again.
The only thing that worked was converting my exe project into a dll project (litterally just changing the Configuration Type of my exe project from Application (.exe) to Dynamic Library (.dll)).
So the question is, can I somehow get my exe project unit-testable using Visual Studio 2012's unit testing or should I just start splitting it up into dlls already?
Edit:
I submitted an issue on Microsoft Connect on this and was told that it is indeed a bug:
https://connect.microsoft.com/VisualStudio/feedback/details/804696/linking-visual-studio-2012-c-unit-testing-project-against-an-exe-causes-access-violations
I've done some more tests using the same solution I attached on completely fresh installs of Windows 7 Pro x64 SP1 and Windows 8.1 Pro Preview x64 on VMware Workstation 9 virtual machines. Nothing but all Windows updates and the specific Visual Studio was installed for each test. I always reverted to a clean snapshot between tests. I also ran all Visual Studios with all-default settings.
On Windows 7, everything I tried gave me the same access violation. I tried my solution with:
Visual Studio Express 2012 for Windows Desktop w/ Update 2
Visual Studio Express 2012 for Windows Desktop w/ Update 3
Visual Studio 2012 Ultimate w/ Update 3
Visual Studio 2013 RC Professional
On Windows 8.1, with Visual Studio Express 2012 for Windows Desktop w/ Update 3 my Unit Tests all ran fine. I'm assuming the other combinations I tried on Windows 7 all work fine on 8.1.
Back on Windows 7, when I switched from x86 to the x64 platform and setting the Default Processor Architecture for the Test Settings to X64 the same test passed. I no longer got access violations.
So this is likely a (Windows 7/x86 platform)-specific problem.
Also, regarding the access violation, it's not always so graceful. I also sometimes get a "vstest.executionengine.x86.exe has stopped working" dialog box with these problem details:
Problem signature:
Problem Event Name: BEX
Application Name: vstest.executionengine.x86.exe
Application Version: 12.0.20827.3
Application Timestamp: 521cc637
Fault Module Name: StackHash_9321
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 00000000
Exception Offset: 00ae9998
Exception Code: c0000005
Exception Data: 00000008
OS Version: 6.1.7601.2.1.0.256.1
Locale ID: 1033
Additional Information 1: 9321
Additional Information 2: 9321642ea520dd869526c054c7161ae9
Additional Information 3: bfae
Additional Information 4: bfaed60192419c1d7d34eac41dbe71a8