简体   繁体   English

Visual Studio C ++将.exe + .dll转换为.exe

[英]Visual Studio C++ turn .exe +.dll into only .exe

I have a program that uses libcurl library. 我有一个使用libcurl库的程序。 After code compiles in order for the .exe file to work I have to put libcurl.dll in the same folder as exe file. 代码编译后,为了使.exe文件正常工作,我必须将libcurl.dll放在与exe文件相同的文件夹中。 Is there a way to add this libcurl.dll file implicitly into the .exe file so it would not require the dll file? 有没有办法将此libcurl.dll文件隐式添加到.exe文件中,因此它不需要dll文件?

You can add any payload to an executable image as a custom resource, including other binaries (see Creating a New Custom or Data Resource ). 您可以将任何有效负载作为自定义资源添加到可执行映像,包括其他二进制文件(请参阅创建新的自定义或数据资源 )。 During application startup you will have to extract the .dll and save it to disk. 在应用程序启动期间,您必须提取.dll并将其保存到磁盘。 This also requires that you mark the library imports as /DELAYLOAD (see Specifying DLLs to Delay Load ). 这还要求您将库导入标记为/DELAYLOAD (请参阅指定DLL以延迟加载 )。 Otherwise the loader will fail due to unresolved imports. 否则,由于未解决的导入,加载程序将失败。

A more natural solution to your problem would be to compile cURL as a static import library and link to it statically. 对您的问题更自然的解决方案是将cURL编译为静态导入库并静态链接到它。 This compiles the libcurl code into your final executable image. 这会将libcurl代码编译为最终的可执行映像。 Instructions on building a static library can be found at How to build cURL static library with SSL support on Windows . 有关构建静态库的说明,请参见如何在Windows上构建具有SSL支持的cURL静态库

You could try using open-source pefrmdllembed to merge the DLL into your EXE file. 您可以尝试使用开源pefrmdllembed将DLL合并到您的EXE文件中。

Commandline: pefrmdllembed.exe -impinj myprogram.exe libcurl.dll myprogram_withcurl.exe 命令行: pefrmdllembed.exe -impinj myprogram.exe libcurl.dll myprogram_withcurl.exe

It will generate new "myprogram_withcurl.exe" that you can ship instead of the original EXE. 它将生成新的“myprogram_withcurl.exe”,您可以发送它而不是原始的EXE。 Should work witb most DLLs. 应该工作大多数DLLs。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Visual Studio C ++ dll项目转换为exe - convert visual studio C++ dll project to exe C ++ Visual Studio .exe消失了 - C++ Visual Studio .exe disappears 如何在 Visual Studio C++ 中构建 exe - How to build exe in Visual Studio C++ Visual Studio C ++ 3rd Party dll阻止.exe运行 - Visual Studio C++ 3rd Party dll's prevent .exe from running 如何在Visual Studio 2010 C ++中使用所需的.dll和lib(opencv)文件制作.exe文件包 - How to make package of .exe file with required .dll and lib (opencv) files in visual studio 2010 C++ 适用于任何 PC 的 Visual Studio 2017 C++ Exe(链接 vcruntime140.dll) - Visual Studio 2017 C++ Exe for any pc (linking vcruntime140.dll) 基于Visual Studio 2005构建的C ++ Exe是否可以动态加载基于Visual Studio 2015构建的DLL - Can a C++ Exe built on MS visual studio 2005 load a DLL dynamically which is built on visual studio 2015 Visual C ++ - 将插件DLL与EXE链接? - Visual C++ - Linking plugin DLL against EXE? 如何在 Visual C++ 中为 DLL 和 EXE 使用相同的堆 - How to use the same heap for DLL and EXE in Visual C++ C ++中带有Bash终端(WSL)的Visual Studio Code仅生成.out文件,而不生成.exe - Visual Studio Code with Bash Terminal (WSL) in C++ builds only .out files - not .exe
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM