[英]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.