locked
Include all the libraries in the exe RRS feed

  • Question

  • Hi, 

    i have written a program in C++ which uses many libraries and include many cpp and hpp files.

    I compile it successfully.

    I run the exe file successfully on my pc but in other pcs i get the message that the msvcp100d.dll file is missing.

    I am using MSVS 2010 and at the output i get the message :

    'das.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Cannot find or open the PDB file ".

    I ignored it all this time after many compiles. I do not know if the fault is here.

    Of course i get many other messages like this.

    But the compile ends successfully without errors.

    I think that i need to include the libraries in the exe but i am not sure.

    Any ideas?

    Thursday, August 23, 2012 5:33 PM

Answers

  • You have to link to the static library. This option may be find in the Project properties:

    Configuration Properties - C++ - Code Generation: Runtime Library

    This should be set to "Multi Threaded" or Multi Threaded Debug".

    I'm sure your Option is currently set to   "Multi Threaded DLL" or Multi Threaded Debug DLL". This setting compiles to the DLL library. That needs that the VC2010 redistibutable must be installed on the PC you want to run your exe. 


    • Edited by Bordon Thursday, August 23, 2012 5:52 PM
    • Marked as answer by Damon Zheng Wednesday, August 29, 2012 6:05 AM
    Thursday, August 23, 2012 5:51 PM
  • To run your exe on other machines without needing additional DLLs you need to set /MT to link the runtime library into your exe.

    Go to Project menu, Properties, Configuration Properties, C/C++, Code Generation and set Runtime Library to /MT in the Release Configuration, then build a Release configuration.

    • Marked as answer by Damon Zheng Wednesday, August 29, 2012 6:05 AM
    Friday, August 24, 2012 12:56 PM
    • Marked as answer by Damon Zheng Wednesday, August 29, 2012 6:05 AM
    Friday, August 24, 2012 2:53 PM

All replies

  • You have to link to the static library. This option may be find in the Project properties:

    Configuration Properties - C++ - Code Generation: Runtime Library

    This should be set to "Multi Threaded" or Multi Threaded Debug".

    I'm sure your Option is currently set to   "Multi Threaded DLL" or Multi Threaded Debug DLL". This setting compiles to the DLL library. That needs that the VC2010 redistibutable must be installed on the PC you want to run your exe. 


    • Edited by Bordon Thursday, August 23, 2012 5:52 PM
    • Marked as answer by Damon Zheng Wednesday, August 29, 2012 6:05 AM
    Thursday, August 23, 2012 5:51 PM
  • I get over 70 errors like

    "

    Error 59 error LNK2005: "protected: char * __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Pninc(void)" (?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ) already defined in BasicExcel.obj C:\Users\Christos\Desktop\DAS\das\das\msvcprtd.lib(MSVCP100D.dll) das

    "

    and 20 warnings?

    Any other idea?

    Thursday, August 23, 2012 6:14 PM
  • Did you perform a rebuild of your complete project? It still seems to me you have remaining parts compiled with link to the DLL library.
    • Proposed as answer by Pintu Shukla Friday, August 24, 2012 2:53 PM
    Thursday, August 23, 2012 7:18 PM
  • Because MSVS is a labyrinth can you explain more clear?

     I have it to the debug mode and pushed the run button.

    I suspect that i have to put the dlls in some specific place...

    • Proposed as answer by Pintu Shukla Friday, August 24, 2012 2:53 PM
    Thursday, August 23, 2012 7:20 PM
  • To your original question:

    You are trying to distribute a debug build of your application (hence the msvcp100d.dll).  This is a no-no as your client PCs won't have the debug runtime files on them and it is not permitted to distribute the C++ debug runtime.

    You can build a release build of your application for distribution.  You will, however, need to provide an installer that installs the C++ runtime on the target PC.

    As an alternative to either you can statically link the C++ runtime into your application and have a program that requires jut the .exe and standard Windows DLL files.  Note that if you are using C++/CLI this is not an option.

    In any case, try rebuilding your project (Build->Rebuild) and see if that cures some of your link errors.  If not, it sounds like your project is trying to link to a .lib file, which itself is built to use the DLL runtime instead of the static runtime.

    • Proposed as answer by Pintu Shukla Friday, August 24, 2012 2:31 PM
    Thursday, August 23, 2012 9:12 PM
  • To your original question:

    You are trying to distribute a debug build of your application (hence the msvcp100d.dll).  This is a no-no as your client PCs won't have the debug runtime files on them and it is not permitted to distribute the C++ debug runtime.

    You can build a release build of your application for distribution.  You will, however, need to provide an installer that installs the C++ runtime on the target PC.

    As an alternative to either you can statically link the C++ runtime into your application and have a program that requires jut the .exe and standard Windows DLL files.  Note that if you are using C++/CLI this is not an option.

    In any case, try rebuilding your project (Build->Rebuild) and see if that cures some of your link errors.  If not, it sounds like your project is trying to link to a .lib file, which itself is built to use the DLL runtime instead of the static runtime.

    I want the second option, a standalone exe. I wrote the code in C++ via MSVS. How can i make this choice to happen?

    I tried rebuilding it but i get the same errors....

    I don't know what to do.


    In order to to achieve my goal do i need to be in debug or realease mode or it doesn't matters?

    • Edited by chtsolak Thursday, August 23, 2012 9:42 PM
    Thursday, August 23, 2012 9:23 PM
  • To run your exe on other machines without needing additional DLLs you need to set /MT to link the runtime library into your exe.

    Go to Project menu, Properties, Configuration Properties, C/C++, Code Generation and set Runtime Library to /MT in the Release Configuration, then build a Release configuration.

    • Marked as answer by Damon Zheng Wednesday, August 29, 2012 6:05 AM
    Friday, August 24, 2012 12:56 PM
  • To run your exe on other machines without needing additional DLLs you need to set /MT to link the runtime library into your exe.

    Go to Project menu, Properties, Configuration Properties, C/C++, Code Generation and set Runtime Library to /MT in the Release Configuration, then build a Release configuration.

    Please read my first carefully my first post. I did that but i get 77 errors.

    Is there a possibility to compile every library, and how can i do that?

    Friday, August 24, 2012 12:58 PM
  • Read this on MSDN

    /MD, /MT, /LD (Use Run-Time Library)

    Now come to your error . Will suggest you to create  a Simple Win32 console project for printing "hello World" and perform your testing with /MT  .Now run it on another system to verify whether it is working fine or not. So by this way you can eliminate possibility of any error due to /MT . Now come to your old project.

    Second read this How to deploy your Project

    In Last in your solution may be some of module use the dynamically-linked CRT, so you won't be able to link the CRT statically unless you recompile all your dependencies to use static CRT.

    Thanks


    Rupesh Shukla


    Friday, August 24, 2012 1:36 PM
  • Read this on MSDN

    /MD, /MT, /LD (Use Run-Time Library)

    Now come to your error . Will suggest you to create  a Simple Win32 console project for printing "hello World" and perform your testing with /MT  .Now run it on another system to verify whether it is working fine or not. So by this way you can eliminate possibility of any error due to /MT . Now come to your old project.

    Second read this How to deploy your Project

    In Last in your solution may be some of module use the dynamically-linked CRT, so you won't be able to link the CRT statically unless you recompile all your dependencies to use static CRT.

    Thanks


    Rupesh Shukla


    I made a hello world exe.

    The release version run succesfully both as "threaded dll" and "threaded"

    The debug version run successfully as "threaded debug"

    It didn't run as "threaded debug DLL"

    I don't know whats happening!!

    Friday, August 24, 2012 2:14 PM
  • What you mean by it didn't run . Does it Shows any error message or anything else.The only difference between them is .They specify which runtime to use. Both use multi-threaded dynamic (DLL) runtimes, but the /MDD version uses the debug version and also defines the _DEBUG symbol for you

    Thanks


    Rupesh Shukla





    Friday, August 24, 2012 2:30 PM
  • What you mean by it didn't run . Does it Shows any error message or anything else.

    Thanks


    Rupesh Shukla

    Yes it shows the same message, that a dll is missing
    Friday, August 24, 2012 2:31 PM
  • What you mean by it didn't run . Does it Shows any error message or anything else.

    Thanks


    Rupesh Shukla

    Yes it shows the same message, that a dll is missing

    And what Dll is missing ? It Should be straight forward.

    Thanks


    Rupesh Shukla


    Friday, August 24, 2012 2:38 PM
  • MSVCP100D.dll
    Friday, August 24, 2012 2:43 PM
    • Marked as answer by Damon Zheng Wednesday, August 29, 2012 6:05 AM
    Friday, August 24, 2012 2:53 PM
  • Yes ok, i should  make a release version which works with the "hello world" on other pcs.

    But it doesn't work with the initial program "das". 

    The whole thread is about this.


    • Edited by chtsolak Friday, August 24, 2012 2:56 PM
    Friday, August 24, 2012 2:56 PM
  • Yes ok, i should  make a release version which works with the "hello world" on other pcs.

    But it doesn't work with the initial program "das". 

    The whole thread is about this.


    This Post was just to make sure that you know /MT and /MD  etc stuff  . And now you learned that part . When you says that it is not running with your old stuff . Read My first post carefully and you will get your answer and don't forget your MSVCP100D.dll issue and how you have to take care of that issue. .

    Thanks


    Rupesh Shukla

    Friday, August 24, 2012 3:00 PM
  • Yes ok, i should  make a release version which works with the "hello world" on other pcs.

    But it doesn't work with the initial program "das". 

    The whole thread is about this.


    This Post was just to make sure that you know /MT and /MD  etc stuff  . And now you learned that part . When you says that it is not running with your old stuff . Read My first post carefully and you will get your answer and don't forget your MSVCP100D.dll issue and how you have to take care of that issue. .

    Thanks


    Rupesh Shukla

    I am new to programming, and i do not fully understand your first post.

    In adddition i do not know anything about MSVCP100D.dll issue...

    Friday, August 24, 2012 3:03 PM
  • Not a problem just read this article .

    Deployment (Visual C++)

    And don't forget if some of module i use the dynamically-linked CRT, so you won't be able to link the CRT statically unless you recompile all your dependencies to use static CRT.

    Thanks


    Rupesh Shukla

    Friday, August 24, 2012 3:10 PM
  • I give up, i can;t do it.
    Friday, August 24, 2012 3:57 PM
  • I give up, i can;t do it.

    Can you upload your Applicatio . If you want us to have a look on your application.

    Thanks


    Rupesh Shukla

    Friday, August 24, 2012 4:14 PM
  • you mean the exe? or all the source files (many MBs)
    Friday, August 24, 2012 4:15 PM
  • you mean the exe? or all the source files (many MBs)

    If many mb's and you are not able to upload do one thing go to your all project and do same linker setting for all the project and recompile your entire solution . It will work fine with you.

    Thanks


    Rupesh Shukla

    Friday, August 24, 2012 4:24 PM
  • http://imageshack.us/photo/my-images/198/21653149.png/

    Here is what i see in MSVS.

    As you can see the solution has only one project and so there only one linker settings.

    So what i have to do?

    The serious problem is that i can not compile a release version while i can build a debug!!!!!!!!

    (I can, but only in Threaded debug DLL mode)
    • Edited by chtsolak Friday, August 24, 2012 4:42 PM
    Friday, August 24, 2012 4:28 PM
  • had tried /MDd option and /MD and /MTd and /MT option inside a simple project and i am not able to reproduce your issue. Right now i am using VS2008 . Already told you all the possible scenario of error and how to resolve them .Now i just can say Good Luck

    Thanks


    Rupesh Shukla

    Friday, August 24, 2012 8:18 PM
  • had tried /MDd option and /MD and /MTd and /MT option inside a simple project and i am not able to reproduce your issue. Right now i am using VS2008 . Already told you all the possible scenario of error and how to resolve them .Now i just can say Good Luck

    Thanks


    Rupesh Shukla

    I do NOT have any problem with hello world.

    (except in debug mode with "threaded debug DLL" option on)

    The problem is in the more complex program called das


    • Edited by chtsolak Friday, August 24, 2012 8:22 PM
    Friday, August 24, 2012 8:20 PM
  • See seeting compiler option will give same effect on all the solution .It's not like it is working different in case of different solution . Second these error can be due to some other reason . Can you show some of the error message and verify your required header file linker file etc. Same time you can perform a comparision between your hello world and project setting and try to set same compiler option and try it once again . May be it will solve your issue.As i have no clue about your das program i am unable to say anything. Thanks

    Rupesh Shukla

    Friday, August 24, 2012 8:37 PM