0

I have this program:

#include <iostream>
#include <string>
using namespace std;

int main() {

    string inputfile = "input.pdf";
    string outputfile = "output.tiff";
    cout << "paste path of pdf to convert" << endl;
    getline(cin, inputfile);
    cout << "type the path of the output file with the correct extension        ie png jpeg or tif" << endl;
    getline(cin, outputfile);
    string command = "gm.exe montage -tile 1x10000 -geometry 85% -density 150x150 " + inputfile + " -quality 100 " + outputfile;

    system(command.c_str());
    return 0;
}

As you can see its using the std library. I did not use a setup project because it felt unnecessary as A could easily just copy and paste the application and the dlls. Before I included dlls in the copy it gave me the following error message:

MSVCP140d.dll is missing and the program cant start.

I got a copy of the DLL from my computer and that seemed to solve the issue, but then when I ran it on the non development computer it gave me:

ucrtbassed.dll is missing and the program cant start.

I downloaded the missing DLL from the internet, but now when I go to launch the program I get this error:

The application was unable to start correctly (0xc0000007b}. Click OK to close the application.

It seems that when a computer has Visual Studio installed the code runs fine; however, when they don't have Visual Studio installed it doesn't run. I have installed the VCredist.exe and the same problem happens.

regards Shrimp

user4581301
  • 33,082
  • 7
  • 33
  • 54
  • @πάντα-ῥεῖ My answer still related here. There are not proper instructions included in answer you marked to be duplicate. See this: http://stackoverflow.com/a/38600728/1836540 – Vyacheslav Napadovsky Jul 26 '16 at 22:20
  • Not sure that's quite the right dupe. This guy is usually the wrong version of the right DLL. – user4581301 Jul 26 '16 at 22:20
  • In other words, I agree with @slavanap – user4581301 Jul 26 '16 at 22:21
  • @user4581301 Well improve the question then, how it isn't, and vote to reopen. – πάντα ῥεῖ Jul 26 '16 at 22:24
  • ^same for @slavanap – πάντα ῥεῖ Jul 26 '16 at 22:25
  • @πάνταῥεῖ Man, it is not a dupe here because author specified precise dlls that are missing, and by these libraries names it is understandable that he is trying to redistribute debug version of the project to another non-developer computer. See my answer below. In question you marked as dupe there's no clues what's wrong with the project (not enough context). – Vyacheslav Napadovsky Jul 26 '16 at 22:31
  • @slavanap Problem lies in the question here, not in the answer. Unless OP doesn't clarify and post a [MCVE]. I won't retract my CV here. Currently there's no harm done, nothing downvoted so what are you bothering about actually? – πάντα ῥεῖ Jul 26 '16 at 22:34
  • @πάνταῥεῖ I insist that is question is different from that you marked as a dupe, because: This a complete project. It doesn't use any libraries. It just has wrong link settings. In the question you marked as dupe, there's project that uses OpenCV .lib file. Probably linking wrong bitness version x64 against x86 (or othervise), or .lib file by OpenCV uses different MSVS runtime library (compiled in different MSVS version). Is that not enough differences? – Vyacheslav Napadovsky Jul 26 '16 at 22:41
  • 1
    @slavanap that's not quite the problem. I'm not voting to reopen because we'd just lock it again. OP's code does not match his problem. There's no need for a windows 10 system dll in any of the posted code. And copying one onto what's probably not a windows 10 computer.... Of course that blows up. Likely that DLL is calling another DLL that has no hope of version matching. OP states right off that they didn't want to build an installer to prevent this aspect of DLL hell. Solution is, to misquote Obiwan Kenobi, "Use the installer, Luke." – user4581301 Jul 26 '16 at 22:41
  • @user4581301 That clarifies a lot. Re-opening and awaiting your better dupe or CV. – πάντα ῥεῖ Jul 26 '16 at 22:44
  • @slavanap Just saying _"I insist"_ is pretty futile. – πάντα ῥεῖ Jul 26 '16 at 22:45
  • @user4581301 that's a different question and it has different solutions. That question is not that related to Windows 10, because there's an security/important windows updates that add ucrtbase.dll to Win7 Win8 and Win8.1. Pay attention that he built DEBUG version ucrtbasse**d**.dll -- that's the issue here. It is not related to installing anything. If you link all runtime libraries statically, the app WILL run on any of Win7, 8.0, 8.1, 10 computer. Without any redistributable packages. That's what my answer exactly points out. – Vyacheslav Napadovsky Jul 26 '16 at 22:45
  • @πάνταῥεῖ I am not good at English when I'm angry. Sorry. – Vyacheslav Napadovsky Jul 26 '16 at 22:46
  • 1
    @slavanap Why are you angry actually?? – πάντα ῥεῖ Jul 26 '16 at 22:47
  • okay so if that is a windows 10 dll then the installer is copying it wrong because when i use the installer from the vs 2010 like setup it copies that exact dll and both systems are running windows 7 in fact i had to add the ucrtbassed dll because it wasnt automaticaly doing that maybe it was because it is in debug mode and i should probably go change it to release – Tactical Shrimp Jul 26 '16 at 22:47
  • @πάνταῥεῖ because I faced both problems myself. They a way different... and annoying!! And someone marked them as a dupe. – Vyacheslav Napadovsky Jul 26 '16 at 22:49
  • 2
    @slavanap I throw my self on my sword. Did some reading on the DLL in question. The world of vcredist changed while I wasn't looking. We are in agreement that most of the problem will go away with the release build and an install of the correct vcredist. Damn near all of it should go away with static static linking, but static linking on Windows has treated me poorly in the past (and can be a security hole). I don't know who downvoted your answer; it looked correct before and still looks correct. – user4581301 Jul 26 '16 at 22:56
  • But note to Shrimp, you do not want to be copying system DLLs from computer to computer. It's a really good way to get the computer out of synch with itself and causes the latter portion of your problem. – user4581301 Jul 26 '16 at 22:58
  • okay i re added the setup and changed it to release thanks for all the help so far lets hope this works – Tactical Shrimp Jul 26 '16 at 23:03
  • @πάνταῥεῖ At this point, now that I've read up on what's going on with `ucrtbase.dll`, I don't have a good dupe (but there has to be one out there, probably with a misleading name) and the code *does* need that dll. – user4581301 Jul 26 '16 at 23:31
  • @user4581301 the code compiled with VS2015 needs `ucrtbase.dll`, but this dll is installed through Windows Update as important update which called like `Windows 10 CRT Update` -- thus no redist package needed. – Vyacheslav Napadovsky Jul 26 '16 at 23:42

1 Answers1

1
  1. Build you project Release version. Not the Debug. Symbol d at the end of .dll name shows that you have built debug version.
  2. Link all libraries statically right clink on Project -> Properties (-> select Release configuration and All Platforms at top of the window) -> C/C++ -> Code Generation -> set "Runtime Library" to "Multi-threaded (/MT)"
  3. Don't forget to escape arguments you pass to command line for other app. I fixed one line of your code. See additional quotes around file names.

    string command = (string)"gm.exe montage -tile 1x10000 -geometry 85% -density 150x150 " +
        "\"" + inputfile + "\" -quality 100 \"" + outputfile + "\"";
    
  • Worth tacking on a recommendation that you make sure you install the correct vcredist version. Make sure you install the version that matches the Visual Studio used to compile the program. – user4581301 Jul 26 '16 at 22:23
  • @user4581301 If you link runtime libraries statically, redistributable package **IS NOT** needed – Vyacheslav Napadovsky Jul 26 '16 at 22:25
  • thank you for all the advice i will try to implament it and swe waht happens – Tactical Shrimp Jul 26 '16 at 22:38
  • @TacticalShrimp Keep an eye on your english spelling and grammar if you're seriously interested in participating this site. – πάντα ῥεῖ Jul 26 '16 at 22:42
  • Okay sorry i was using a smartphone with tiny keys and i have a visual imparement so seeing what i type on such small devices is difficult at best. But i will try to keep that in mind. – Tactical Shrimp Jul 26 '16 at 22:51
  • so on your step 3 visual studio gives me a red line on the "\" and gives a little tip that reads "expression must have integral or uncoped enum type" at least i think thats what it says its hard to read because it doesn't zoom with he rest of my system and i have a large visual impairment – Tactical Shrimp Jul 26 '16 at 23:07
  • @TacticalShrimp oh, excuse me. I forgot to cast first string to `(string)`. Fixed my answer. P. S. You can't do `char* + char*`, but you can `string + char*`, `char* + string` and `string + string` – Vyacheslav Napadovsky Jul 26 '16 at 23:10
  • Tweak: rather than the cast, I recommend going all in and being blatant: `string("gm.exe montage -tile 1x10000 -geometry 85% -density 150x150 ")` Same amount of work done and absolutely no confusion. – user4581301 Jul 26 '16 at 23:16
  • Well i will try that but it seems to work in its unedited form however all the other things worked and my problem is solved thank you very much. – Tactical Shrimp Jul 27 '16 at 00:03
  • okay so scratch part 3 that actually kills the script because the method my Technion uses to paste the path includes all those things so i was sitting there wondering what was wrong and that was so yea just thought i would mention that – Tactical Shrimp Jul 27 '16 at 22:18
  • @TacticalShrimp What do you mean? – Vyacheslav Napadovsky Jul 27 '16 at 22:46
  • @slavanap well when they copy the directories into the command line it puts the \es and "s in for them so what was happening was that it as doing double \s and was not working properly – Tactical Shrimp Aug 02 '16 at 02:08
  • @shrimp yeah. Double protection does not always look as expected. That quotes are a security hole, too btw. – Vyacheslav Napadovsky Aug 02 '16 at 04:18