当我使用 dll 时出现 .lib 错误?
我正在尝试使用 Windows DLL 进行一些练习(不习惯它们)。我关注了这篇文章:
http://msdn.microsoft.com/en- us/library/ms235636(v=vs.80).aspx
致信。
然而,我收到此错误:
1>LINK : fatal error LNK1104: 无法打开文件 '..\debug\math.lib'
我的项目是 dll 项目,而不是 lib。而且根本没有从我的项目(整个解决方案)创建任何库。
有人知道出了什么问题吗?
I'm trying to get some practice using windows DLLs (not used to them). I followed this article:
http://msdn.microsoft.com/en-us/library/ms235636(v=vs.80).aspx
To the letter.
And yet, I am receiving this error:
1>LINK : fatal error LNK1104: cannot open file '..\debug\math.lib'
My project is a dll project, not a lib. And there are no libs created from my projects at all (the whole solution).
Anybody have any idea what's wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果 dll 实际上没有导出任何内容,VS 不会创建导入库。要快速检查是否属于您的情况,请找到您的 dll,使用 dependency walker 打开它,然后查看是否有任何导出。
如果您发现导出丢失,请检查您是否确实标记了任何导出内容:通过将类/函数声明为“__declspec( dllexport )”(当标头包含在 dll 中时,当 exe 包含时使用 dllimport ),或者 extern “C” 加模块定义(.def) 文件。
VS does not create an import library if dll does not actually export anything. To quickly check if that is your case, find your dll, open it with dependency walker and see if there are any exports at all.
If you find exports missing check if you did mark anything for export: either by declaring classes/functions as "__declspec( dllexport )" (when header is included in dll, dllimport when included by exe), or extern "C" plus module definition (.def) file.
您的 .dll 项目可能正在创建导入 .lib。这简化了 DLL 的使用。 import .lib 是一个简单的库,与您的 dll 具有相同的功能,但它没有实现 - 当您使用它时,它会加载 dll,然后将您对 dll 进行的调用转发。
或者,控制台项目可能认为您有一个导入 .lib - 但实际上没有。
创建/使用 dll 的说明有点奇怪。我不会那样做(使用“添加引用”对话框)。您可能需要查看项目设置,看看是否看到任何对 math.lib 的引用,或者任何有关创建导入 .lib 的内容。
另外,检查 .dll 项目上的输出目录并查看是否创建了 math.lib(或任何 .lib)。
Your .dll project could be creating an import .lib. This simplifies using a DLL. An import .lib is a simple library that has the same functions as your dll, but it doesn't have the implementation -- when you use it, it loads the dll and then forwards the calls you make to the dll.
Or, the console project might think you have an import .lib -- but you don't.
The instructions for creating/using a dll you have are a little odd. I don't do it that way (with the Add References dialog). You might need to look through your project settings and see if you see any reference to math.lib -- or anything about creating an import .lib.
Also, check your output directories on the .dll project and see if math.lib (or any .lib) was created.
这可能是由于一些简单的事情造成的,例如您可能为主项目添加了对 DLL 项目的依赖。
在 Visual Studio 2008 中,可以在以下位置找到该设置:
项目依赖项
,只需取消选中 DLL 项目即可解决问题。此外,您还可以验证:DLL“库”的路径不再包含在主项目的“链接器”命令行中:
Configuration Properties >链接器>命令行
This could be due to something as simple as the dependency you might have added for your main project upon the DLL projects.
In visual studio 2008 the setting can be found at:
Project Dependencies
and simply un-checking the DLL projects will solve the problem.Additionally you can verify that: the path to the DLL 'Lib's are no longer included in the 'linker' command-line of your main project at:
Configuration Properties > Linker > Command Line