How to make a c++ project run on a different PCs - c++

I developed a small c++ program in Visual Studio 2012 on Windows7, 64bit (let's call it PC1). On that pc it runs fine!
Since I didn't have a versioning control system like SVN at hand, I copied ALL the project data (the exact folder structure, DLLs, source files, project files...) to a usb stick and moved it to another computer.
On that other engine there's Visual Studio 2010 on Windows7, 64bit (PC2).
So I just changed the platform toolset to v100 as described here.
I successfully compiled the project on PC2 (clean, build) and wanted to run the exe, but the command prompt stayed empty.
I then tried to debug and added a breakpoint at the very first line of main - which wasn't reached, the command prompt was still empty.
Ok, a usb stick is certainly not the most secure solution for data storage, so I gave it another try and moved it again - the problem remains.
Visual Studio's output on PC2 is the same as on PC1, so I couldn't find any anomalies there.
Yeah, there might be many error sources, so where can I start?
And how can I get a more verbose output for troubleshooting?
Or is this even a common phenomenon (perhaps due to different VS versions) and there's an simple way fix it?

This is not a full solution, but at least I'm a tiny step ahead:
In my last comment I wrote:
I took your advices into account and created a brand new project on PC2, VS2010. I exactly followed this guide: http://frozenhamster.wordpress.com/2011/02/11/lapack-on-windows-with-visual-studion-2010/
That didn't work either, so I removed I "out-commented" everything except for a single cout. Voila, that worked!
But as soon as I make use of the desired Armadillo (LAPACK and BLAS), the project compils but does not run.
What's going wrong here?
I don't get any compiler errors!

Related

Visual Studio cannot start debugging for C++ project 0x80070057

Randomly (and infrequently), Visual Studio (2017) will abruptly refuse to run my C++ project. This will suddenly start happening in the middle of a session.
Visual Studio will still build the project and generate the executable, however, the following cryptic error message appears every time I want to run my program. No changes were made to the configuration or project and it strangely happens after an innocent build.
(It goes without saying but I tried extensively checking for solutions to this problem and no solution worked or was applicable)
Whether I add a new configuration setting or play with the existing settings (Release/Debug, x86/x64), nothing fixes it except performing a full repair (and that takes a very long time). Creating a new project didn't help either, but running it in VS 2015 is successful.
This happens approximately once a week, so I would greatly appreciate knowing how this error can be fixed (or at least avoided).
After some more experience with it, it appears just to be an issue with Visual Studio when builds are too large and executed too often (it happened to multiple computers). More specifically, it could come about as a result of using many templates and applying a large number of explicit template specializations. By building with only the template specializations I need for testing, the issue doesn't come up.
This is usually caused by VS mixing release and debug binaries for me. I have a script which cleans all the output directories, including the garbage VS puts into the projects .vs and Windows Temp folder. This always fixes the issue for me.

When I execute an .exe (compiled on my machine) on another computer it give me this error

It's my first time using Visual Studio 2017. I built a simple program in C++ on my PC. I was curious to see if my program works on another PC. I tried to execute the .exe on the other computer and it gave me this kind of error:
vs(some letters and numbers).dll is missing.
I assume that the .dll in question is part of Visual Studio.
I tried on a third PC, and this time the cmd stops working and becomes unresponsive after I execute my .exe.
I also have this problem when I compile with MinGW using the g++ compile feature in the cmd. When I execute the program compiled with MinGW on another PC, it gives me the same error, but this time it says something like
gw...dll is missing
Is there a way to avoid this error without installing the Visual Studio (or MinGW at this point) on any other PC I want my program to run on?
If you're interested in the code, I can put it here, but I don't think it's the problem here because I have the same issue for every other .exe compiled on my PC.
Here's a picture of the error:
In case of Visual Studio, you need to install Visual C++ Redistributable libraries or provide the libraries that are required by your application with .exe file (I am not sure if it violates license or not though).
In case of MinGW, you need to provide required DLL as well. I guess that you need libgcc_s_dw2-1.dll and libstdc++-6.dll, but you would better check it yourself. And remember about the license.
You may use Dependency Walker to analyse dependencies of your application.
UPDATE (2017-12-12):
I've missed the time you posted the screenshot. As far as I see from it the problem is that you are trying to run debug version of your executable: ucrtbased.dll is the debug version of the ucrtbase library and is only available (from what I know) from Visual Studio distribution. If you want to run your application on the computers that do not have installed Visual Studio, then you should use the Release version of your application.
In order to understand your problem you need to understand the concept of DLL.
Dynamic-link library(DLL) - As described by Microsoft:
A DLL is a library that contains code and data that can be used by
more than one program at the same time. For example, in Windows
operating systems, the Comdlg32 DLL performs common dialog box related
functions. Therefore, each program can use the functionality that is
contained in this DLL to implement an Open dialog box. This helps
promote code reuse and efficient memory usage.
So to put it simply, DLL is basically a bunch of compiled code, which is being linked to your code at load (or even run-time). Now, of course if your system is missing the DLL, your progrem will fail to work. To make things even worse, DLL are sensitive to the compiler that was used. So each DLL might have multiple version, so you will need to right DLL.
Now to the problem itself, the error message are the best way to start. They guide you what DLL are missing, and what is their name. For instance in your case "vs*.dll" is most likely related to Visual C++ runtime redistributable.
Finally, please note you have another consideration to make in addition to make your own system work: Every one that will use your code might face the exact same problem. So if you actually intend to share your .EXE with other people, you will need to understand how to guide them, or even automate their installation process.

Getting "0xc000007b Application Unable to Start Correctly" error on only one computer

I am building an application, and I just pulled the source code onto a new computer. I am able to compile and build the program on the new computer, but when I try to run the executable I get an "Application start correctly" error.
I can take the executable that was built on the problem computer run it on my other machines and it works fine. Dependency Walker doesn't highlight any obvious deficiencies; the output looks similar to the output from the functioning machines. I also reinstalled the VS C++ redistributable.
It seems like there must be some way in which the environment on the new computer is different, but I don't know where or how to start looking.
All credit to #PaulMcKenzie in the comments above. My problem ended up being that I'm using an x64 application, and my Windows search path was finding and trying to use x86 DLLs, which caused the crash. I found this out through a closer examination of the Dependency Walker output.

My program doesn't run on some PCs

I'm working in a project building an application with Computer Vision using C++, OpenCV and Visual Studio. I'm no expert in deploying programs to use them on other PCs.
I've made a program which I need to distribute to a certain amount of people and I can't make it work on all the computers I'd like to. The program was written using Visual Studio 2015, it's an MFC Project and the code is written in C++ since I'm using OpenCV.
When it was finished, I tried to run it on another computer and I realized that it won't open. I looked on the Internet and found out that I needed to statically link the libraries, so I did it. Also, when I was looking for information, I found that Visual Studio 2015 builds its projects so you can run the programs on machines with Win7 to Win10. When I learnt that, I tried to open it on PCs running Windows 7, 8, 8.1 and 10. I tested my program in like 20 computers, give or take.
The results? I couldn't make it work for Windows 7, the error ucrtbase.terminate api-ms-win-crt-runtime-l1-1-0.dll showed every time I tried to open it. It also didn't open in one machine with Windows 8 without showing any error message, but it DID open on most of the machines with Win 8.1 and Win 10. The thing is that "most"; there were some PCs (with Win 8.1 and 10) that I couldn't open my program on. I found that sometimes it would show up in the Task Manager for less than a second and then disappear. The most stressful thing is that it doesn't tell me what the problem is, it doesn't show any error message. It just won't open.
I tried using Dependency Walker (both on my PC and one of those that I couldn't run my program on) to see if there's something missing and I got a reeaaally long list of files that the system couldn't find, here's an example:
List 1/11. Something curious is that my program executes just well on my computer and on those I could open it, even though Dependency Walker (DW) tells me that there might be a problem with it. This indicates me that DW is not finding the exact error I'm having.
Another thing I've tried is to compare the things I have installed on my computer and install them on the one I want to execute my program on. I tried installing .NET Framework 4.6.1 just because VS 2015 says that my project was built using it (and I have it installed in my PC and that other one doesn't. Also I tried with .NET 4.6.1 SDK). Nothing changed.
Just look here:
https://msdn.microsoft.com/de-de/library/ms235299.aspx
The quick-and-dirty way would be to copy the DLLs from your redist directory. For my MS VS 2013 it is hidden under the VS installation directory in:
VC\redist\x86
or
VC\redist\x64
...
which depends on your application.

Source code is different from original version?

I'm setting break points in Visual Studio before running the Local Windows Debugger, and they all say this when the debugger is running, with a small warning label on each break point. I can't see why this would be happening; people have talked about using different versions of Visual Studio and getting this error, but I made this project earlier today, pasting the base code from my professor into a new project created on my copy of Visual Studio 2012.
I found this when trying to fix a strange error in my program that wouldn't go away even though I manually fixed things (it was a string error that claimed I was using an index outside the bounds of the string; setting this value to 0 explicitly did not fix it) so I presume that this is the actual culprit.
Make sure you're properly building the code (Build Solution or Rebuild Solution).
In the output panel you should now be able to locate where the binaries are located.
Make sure you're debugging the said binaries by looking in the Debugging page of your project properties, the Command property should most likely be set at $(TargetPath).
Other things to look for. The project should be "Set as startup project", the program database option should be activated (by default). Don't modify the source after you started debugging.