C++ How to compile dll in a .exe(C++ 如何在 .exe 中编译 dll)
问题描述
我正在创建一个 C++ 程序,但我希望能够仅向用户提供一个 .exe 文件.但是,我正在使用包含一些 dll 的库(curl 等).是否可以将这些 dll 编译到 .exe 文件中?
I am creating a c++ program, but I want to be able to offer just a .exe file to the user. However, I am using libraries (curl among others) which have some dll's. Is it possible to compile these dll's into the .exe file?
我使用 Code::Blocks 和 mingw.
I use Code::Blocks and mingw.
推荐答案
为了实现这一点,您需要 静态链接.这要求您的所有库(以及它们递归依赖的库)都需要作为静态库使用.请注意,可执行文件的大小会很大,因为它将携带来自这些静态库的所有代码.这就是为什么首先发明共享库 (DLL) 的原因是为了能够在应用程序之间共享公共代码.然而,这并不总是在 在 Windows 上运行得很好.
In order to achieve that you will need static linking. This requires that all your libraries (and the libraries they depend upon recursively) need to be available as static libraries. Be aware that the size of your executable will be large, as it will carry all the code from those static libraries. This is why shared libraries (DLLs) were invented in the first place, to be able to share common code among applications. However that does not always work so well on windows.
我认为您可能真正想要的是一个 安装程序 来安装您的可执行文件及其所有依赖项图书馆.
I think what you may really want is an installer that installs your executable and all it's dependent libraries.
这篇关于C++ 如何在 .exe 中编译 dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++ 如何在 .exe 中编译 dll


基础教程推荐
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01