C ++如何在.exe中编译DLL [英] C++ How to compile dll in a .exe

查看:190
本文介绍了C ++如何在.exe中编译DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个c ++程序,但是我希望能够向用户提供一个.exe文件。但是,我正在使用有些DLL的卷(其他)。可以将这些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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆