开发者

.lib error when I'm using a dll?

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).

开发者_StackOverflow社区

Anybody have any idea what's wrong?


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜