Running C ++ application built by VC ++ Express on another computer

Source: Internet
Author: User
Tags winsxs folder

Another FAQ from VC ++ Express users is: "I give my vc ++ application to my friend, and it does not run on her computer. "This happens because VC ++ DLLs have to be redistributed to another computer together with this application.

 

There are three ways to get an application built with VC ++ express 2005 to run on another computer that does not have VC ++ express installed:

  1. Ask user of that computer to install visual c ++ redistributable package (vcredist_x86.exe) to install all visual C ++ libraries as shared side-by-side assemblies into the native Assembly Cache (winsxs folder ). this package can be downloaded from the Microsoft download site Microsoft Visual C ++ 2005 redistributable package (x86 ). redistributing visual c ++ libraries using this package is recommended for applications built with Visual C ++ Express.

  2. Build another installer of VC ++ libraries using redistributable merge modules installed by VC ++ express into common files \ merge modules. I am describing this approach below in more details.

  3. statically link your application to VC ++ libraries. I recommend against statically linking because static linking prevents your application from running against the most up todate version of VC ++ libraries installed on your computer. for example, consider an application that is statically linked to a particle library, running on a client computer with a new version of this library. the application still uses code from the previous version of this library, and does not benefit from library improvements, such as security enhancements.

So if you have decided that you cannot use Microsoft Visual C ++ 2005 redistributable package (x86) and wisely avoid statically linking to VC ++ libraries, you may build a custom MSI that deployes VC ++ libraries using four merge modules with CRT library installed by VC ++ Express. in my case there are installed in D: \ Program Files \ common files \ merge modules \:

D: \ Program Files \ common files \ merge modules \

Microsoft_vc80_crt_x86.msm

Policy_8_0_microsoft_vc80_crt_x86.msm

Microsoft_vc80_debustmt_x86.msm

Policy_8_0_microsoft_vc80_debustmt_x86.msm

Clearly I assume that you have read the EULA and redist.txt and do understand that redistribution of debug applications is not allowed. you can simulate redist of DEBUG binaries in your office, but if it goes outside to another computer, it must be application build in release mode. so please read the EULA and redist.txt carefully and understand what you can and what you cannot redistribute.

I am going to show now how to one can use msms to install VC ++ DLLs to another computer. I have VC ++ express installed on my computer and I want to make it run on another computer that does not have VC ++ 2005 installed. here is what I do:

1. I download Wix from sourceforge.net, here is the link http://sourceforge.net/projects/wix. More specific I am going to download from this link, http://prdownloads.sourceforge.net/wix/binaries-2.0.3220.0.zip? Download but you may use another build of Wix, perhaps more recent or older then one I use.

2. I am going to unzip this package to D: \ Wix \

3. Now I am going to open Visual Studio 2005 command prompt (Start> All Programs> VISUAL C ++ 2005 express edition> Visual Studio Tools> Visual Studio 2005 command prompt)

4. I am typing uuidgen-N2 and click Enter. This generates two uuids for me that I am going to use later in Step 6.

5. Now I am going to create two XML files in D: \ Wix. First vccrt. wxi, second vccrt. WXS.

6. First, I am creating D: \ Wix \ vccrt. wxi with the following content:

<Include>

<? Define product_id = !!!! ReplaceUuid1From step 4 !!!! ?>

<? Define package_id = !!!! ReplaceUuid2From step 4 !!!! ?>

</Include>

Attn: I am going to use two uuids generated for me by uuiedgen.exe in the step 4 to define product_id and package_id. on purpose, I am not listing UUID generated for me, so to help readers of this article avoid using same UUID as someone else.

7. Second, I am creating D: \ Wix \ vccrt. WXS with following content

<? XML version = '1. 0'?>

<? Include $ (SYS. sourcefiledir) \ vccrt. wxi?>

<Wix xmlns = 'HTTP: // schemas.microsoft.com/wix/2003/01/wi'>

<Product ID = '$ (var. product_id )'

Name = 'msi to redistribute my app'

Language = '000000' version = '1. 0.0.0 'manufacturer = 'me'>

<Package ID = '$ (var. package_id )'

Description = 'msi to redistribute my app'

Comments = 'msi to redistribute my app'

Manufacturer = 'me'

Installerversion = '000000'

Compressed = 'yes'/>

<Media id = '1' cabinet = 'vccrt. cab' embedcab = 'yes'/>

<Directory id = 'targetdir' name = 'sourcedir'>

 <Merge id = 'crt 'language = '0' src = 'd: \ Program Files \ common files \ merge modules \ microsoft_vc80_crt_x86.msm 'diskid = '1'/>

 <Merge id = 'crt policy' Language = '0' src = 'd: \ Program Files \ common files \ merge modules \ policy_8_0_microsoft_vc80_crt_x86.msm 'diskid = '1'/>

</Directory>

 <Feature id = 'crt _ winsxs 'Title = 'crt winsxs' level = '1'>

<Mergeref id = 'crt '/>

<Mergeref id = 'crt policy'/>

</Feature>

<Installexecutesequence>

<Removeregistryvalues/>

<Removefiles/>

<Installfiles/>

<Writeregistryvalues/>

</Installexecutesequence>

</Product>

</Wix>

8. Now I am going back to command line, change current directory, compile and link MSI

    1. > Cd D: \ Wix
    2. > Candle.exe vccrt. WXS-out vccrt. wixobj
    3. > Light.exe vccrt. wixobj-out vccrt. MSI

    9. That's it, MSI is created. It shoshould be a file D: \ Wix \ vccrt. MSI. If you see errors, take a look on troubleshooting section below.

    10.Now I copy my application and vccrt. msi to another computer where I want this application to run which does not have VC ++ express installed. after I have copied my EXE and vccrt. msi, I will first run vccrt. MSI before running my exe.

    11. Well my application works just fine. If your application does not start after MSI is installed, please see troubleshoting section below.

    Troubleshooting:

    1. error message cndl0054 from candle.exe

    Candle.exe: Error cndl0054: The document element name 'include' is invalid. A Wix source file must use 'wix' as the document element name.

    Cause:You have tried executing> candle.exe vccrt. wxi-out vccrt. wixobj instead of> candle.exe vccrt. WXS-out vccrt. wixobj

    2. error message cndl0009 from candle.exe

    D: \ Wix \ vccrt. WXS (6): Error cndl0009: the product/@ ID attribute's value ,'!!!! Replace with UUID from step 4 !!!! ', Is not a legal guid value.

    D: \ Wix \ vccrt. WXS (10): Error cndl0009: the package/@ ID attribute's value ,'!!!! Replace with UUID from step 4 !!!! ', Is not a legal guid value.

    Cause:Edit vccrt. wxi and replace !!!! Replace with UUID from step 4 !!!! With UUID generated in Step 4

    3. error message cndlxxxx from candle.exe

     Cause:No idea, mistake happen when you copy/pasted XML from this post. See Wix documentation for troubleshooting.

    4. Error on start of application either a message box that says "This application has failed to start because the application configuration is incorrect" or "the system cannot execute the specified program"

    Cause:First, check that your application is built in release mode. if it was debug application, you will see OS errors that let you know that either msvcm80d. DLL or msvcr80d. DLL is not loaded. second, check if you have deployed all dependencies of this application. use depends.exe to see dependencies of an application

    5. error message box while starting your application that says "to run this application you first must install. NET Framework of version v.2.0.xxxx ".

    Cause:You application contains managed code and depends on presence. net Framework. for C ++ applications it means that it has been compiled as/CLR,/CLR: pure or/CLR: safe. you have install. net Framework.

    6. after you have installed MSI and you run your application you still get errors described on this page in msdn, please make sure you have done all steps exactly as they are described and repeat them. also check out general troubleshooting section in msdn docs for issues around deployment of Visual C ++ libraries.

     

    for any additional help with redistributing applications built with VC ++ Express, please check out discussions or ask your question on VC ++ forums, http://forums.microsoft.com/MSDN/ShowForum.aspx? Forumid = 29 & siteid = 1.

    Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.