Using the Ceres nonlinear optimization library in the windows system: (3) Publishing applications

(1) Install the Ceres library

(2) Call the Ceres library

(3) Release the application

        1. Integrate DLL library into exe application

                1.1.Sewing.Fody

                1.2. ILMerge and ILMergeGUI

                1.3.WinRAR

        2. Make the installation package

 (3) Release the application

In C# projects, some external DLL libraries are often referenced. When publishing, these libraries must be released together with the executable program, otherwise the program will not be able to run. One is to directly release the green version software after integrating the DLL into the exe file, and the other is to make an installation package for the program and install it locally.

1. Integrate DLL library into exe application

The DLL can be directly embedded into the project as a resource, or a third-party tool can be used to integrate the DLL and the exe. See this article for specific routines:

https://haolaoshi.blog.csdn.net/article/details/102502693

It is said that the default resource embedding method of VS is only good for managed DLLs (that is, .NET-based DLLs), and does not work for unmanaged DLLs (such as C++ DLLs). I tried it without success, so I gave up. Of course, it may be that I did something wrong. And to package or embed unmanaged DLL, it can be easily achieved with the help of third-party tools. The following mainly introduces several common third-party tools to integrate DLL and exe. Refer to the following article:

https://www.cnblogs.com/sndnnlfhvk/p/5547427.html

1.1.Sewing.Fody

You can directly merge dependent DLLs into the target exe during the build phase, and support unmanaged DLLs for mixed mode packaging. The disadvantage is that you can only merge DLLs into exe, and it does not support merging one DLL into another DLL.

Costura.Fody download address: GitHub - Fody/Costura: Embed references as resources

If it is a managed DLL that the project depends on, after installing Fody and Costura.Fody through Nuget, these managed DLLs will be automatically merged into the target exe during the project compilation phase.

For unmanaged DLLs (such as C++ DLLs), we need to add these DLL names in the FodyWeavers.xml file in the project (note that the name does not have a .dll suffix). If there is no FodyWeavers.xml file in the project, you can go to the project Add this xml file in.

  In addition, you need to create a new folder in the project. If your DLL is 64-bit, then the folder name is Costura64. If your DLL is 32-bit, then the folder name is Costura32. Then copy all your DLL files to this folder, and this folder in the project should also be added accordingly.

 Finally, set the properties of these DLLs to "embedded resources". After all settings are completed, you can compile the project to get the packaged exe, copy this exe to another computer and run it directly.

 Reference article:

C#(.Net) embeds unmanaged dll into exe - Tencent Cloud Developer Community - Tencent Cloud

1.2. ILMerge and ILMergeGUI

It supports merging DLLs that EXE depends on into EXE, and also supports merging other DLLs that the main DLL depends on into one DLL.

ILMerge download address:

https://www.microsoft.com/en-us/download/details.aspx?id=17630

ILMergeGUI download address:

http://ilmergegui.codeplex.com/

1.3.WinRAR

Using WinRAR to make files that automatically decompress and run can also meet our needs. For details, please refer to this article:

https://www.cnblogs.com/fxd980519/articles/4807756.html

2. Make the installation package

(1) The release tool that comes with VS

Remember to select the corresponding .NET Framework version and the system-level runtime library version that users can install online.

(2) Install the package publishing plug-in Microsoft Visual Studio Installer Projects

 Tutorial:

https://www.cnblogs.com/ttcbk/p/14875456.html

references

[1] Zhang Hu, Robot SLAM Navigation Core Technology and Practice [M]. Machinery Industry Press, 2022.

Guess you like

Origin blog.csdn.net/m0_68732180/article/details/130234858