简体   繁体   中英

Visual Studio C++ turn .exe +.dll into only .exe

I have a program that uses libcurl library. After code compiles in order for the .exe file to work I have to put libcurl.dll in the same folder as exe file. Is there a way to add this libcurl.dll file implicitly into the .exe file so it would not require the dll file?

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. This also requires that you mark the library imports as /DELAYLOAD (see Specifying DLLs to Delay Load ). 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. This compiles the libcurl code into your final executable image. Instructions on building a static library can be found at How to build cURL static library with SSL support on Windows .

You could try using open-source pefrmdllembed to merge the DLL into your EXE file.

Commandline: 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. Should work witb most DLLs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM