如何在Visual C ++中构建一个导入库(.lib)和一个DLL? [英] How do I build an import library (.lib) AND a DLL in Visual C++?

查看:126
本文介绍了如何在Visual C ++中构建一个导入库(.lib)和一个DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一个Visual Studio项目构建一个DLL文件和一个导入库(.lib)文件。 (导入库是一个静态链接的库,负责将该DLL文件加载到其他使用它的项目中)。



所以我去了Visual Studio C ++ 2008 Express版本创建了一个类型类库的新项目,并将配置类型设置为Dyanamic Library(.dll)。



但是当我构建解决方案,我看到的唯一相关输出文件是一个DLL文件;我看不到任何LIB文件生成。我查看项目目录和所有子目录(Release and Debug)。



我相信可以同时构建一个LIB和一个DLL文件,因为< MSDN上的一个href =http://msdn.microsoft.com/en-us/library/d14wsce5.aspx =nofollow noreferrer>它说链接器在构建DLL时创建导入库。 另外,本网站的另一个用户正在使用Visual C ++创建LIB和DLL文件



那么我该怎么做?

解决方案

通过选择类库,您不小心告诉它使用C ++的CLI(托管)扩展来制作一个.Net库。 / p>

相反,创建一个Win32项目,并在下一页的应用程序设置中选择DLL。



你也可以从那些制作一个MFC DLL或ATL DLL图书馆的选择,如果你想去那条路线,但它听起来像你没有。


I want to have a single Visual Studio project that builds a DLL file and an import library (.lib) file. (An import library is a statically-linked library that takes care of loading that DLL file in other projects that use it).

So I went to Visual Studio C++ 2008 Express Edition, created a New Project of type Class Library, and set the "Configuration Type" to be "Dyanamic Library (.dll)".

But when I build the solution, the only relevant output file I see is a DLL file; I don't see any LIB file getting generated. I looked in the project directory and all subdirectories (Release and Debug).

I believe that it is possible to build a LIB and a DLL file at the same time because on the MSDN it says "The linker creates the import library when the DLL is built." Also, another user of this website is creating LIB and DLL files at the same time using Visual C++.

So how can I do it?

解决方案

By selecting 'Class Library' you were accidentally telling it to make a .Net Library using the CLI (managed) extenstion of C++.

Instead, create a Win32 project, and in the Application Settings on the next page, choose 'DLL'.

You can also make an MFC DLL or ATL DLL from those library choices if you want to go that route, but it sounds like you don't.

这篇关于如何在Visual C ++中构建一个导入库(.lib)和一个DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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