定义文件(.def) [英] definition file (.def)

查看:87
本文介绍了定义文件(.def)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个带有.def文件的Library-Project。 (我使用Visual Studio 2010)

我将这个项目包含在一个带有.exe项目的解决方案中,它应该使用这个.lib。



但是当我尝试使用lib的函数时,我得到一个链接器错误:外部符号(LNK1120)。



这意味着它无法找到该函数。 ...为什么?



- 我设置所有dependecies,包括带有.exe项目中导出函数的Header。



我想现在,.def文件可能有问题:



.def文件的重要部分:



出口

ZpArchive

ZpVersion

ZpInit

ZpSetOptions

ZpGetOptions



这些是函数,.lib项目应该导出。

我是否必须写功能的基础(我没有写这个.def文件)?或者这是正确的方法吗?





感谢任何帮助..

hi all,

I have a Library-Project with a .def file. (I use Visual Studio 2010)
I included this project in a solution with an .exe Projects, which should use this .lib.

But when i try to use a function of the lib, i get a linker-error: external Symbol (LNK1120).

This means it cannot find the function.... why?

- i set all dependecies, included the Header with the exported functions in the .exe Project.

I think now, it is possibly something wrong with the .def file:

the important part of the .def file:

EXPORTS
ZpArchive
ZpVersion
ZpInit
ZpSetOptions
ZpGetOptions

which are the functions, the .lib Project should Export.
Do i have to write the argements of the functions too (i didnt write this .def file)? or is this the right way?


thanks for any help..

推荐答案

如果您收到链接器错误,则表示您的def文件不完整,请参阅 http:// msdn .microsoft.com / zh-gb / library / d91k01sh.aspx [ ^ ]。
If you get linker errors then it means your def file is incomplete, see http://msdn.microsoft.com/en-gb/library/d91k01sh.aspx[^].


使用LIB时,应编译它并将其放在将使用它的项目源的目录下。



然后记得进入项目属性并通过库设置依赖关系。



例如如果您的库被称为 myZip.lib ,您应该使用lib进入项目的项目属性,在Linker->输入中添加附加依赖lib的名称,即 myZip.lib。



记住相对于th的相对路径e项目目录,第一次可能需要一两次尝试。



希望有所帮助,

Denis





编辑:我一如既往地读得太快,错过了一些积分,原谅我。



它错过了哪些功能?导出的函数是否声明为__stdcall?可能需要这样才能工作。
When you use a LIB you should compile it and place it under a directory of the source of the project that will use it.

Then remember to go in the project properties and set the dependency by the library.

For example if your library is called myZip.lib you should go in the project properties of the project using the lib, under Linker->Input add in the "Additional dependecies" the name of the lib, i.e "myZip.lib".

Mind the relative path with respect to the Project dir, it might need one or two tries the first times.

Hope that helps,
Denis


as always I read too fast and misse some points, forgive me.

Which functions does it misses? Are the exported functions declared as __stdcall? It might need that in order to work.


这篇关于定义文件(.def)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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