帮助理解 Makefile.in 中的 EXPORTS
在 linux (ubuntu) 上现有的 c++ 项目的 Makefile.in 中,有这样的内容:
EXPORTS = \
gtkmozembed.h \
gtkmozembed_glue.cpp \
gtkmozembed_internal.h
你能告诉我 EXPORTS 是什么意思吗?
谢谢。
In the Makefile.in of an existing c++ project on linux (ubuntu), it has this:
EXPORTS = \
gtkmozembed.h \
gtkmozembed_glue.cpp \
gtkmozembed_internal.h
Can you please tell me what does EXPORTS mean?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
EXPORTS 只是文件列表的名称。这可能意味着这些文件被安装到其他人可以使用它们的位置。具有库用户不感兴趣的实现细节的头文件可以保持私有。
EXPORTS 中的 .cpp 文件可能意味着它包含用户必须编译并链接到其项目中的骨架代码。
您的示例来自 Firefox。它的定义是:
在 Makefiles 中复制或安装文件有点问题。请注意,副本与其原始版本之间不存在依赖关系。
EXPORTS is just the name of a list of files. It might mean these files are being installed to a location where others can use them. Header files with implementation details not of interest to the user of a library can be kept private.
A .cpp file in EXPORTS can mean it contains skeleton code users have to compile and link into their projects.
Your example is from Firefox. It's defined as:
Copying or installing files in Makefiles is a bit problematic. Note that there is no dependency between the copy and its original.
想象一下:
您是库(DLL)的设计者。你必须定义库必须做什么......然后你就可以编写它。很多进程都可以使用你这个DLL中的函数,你的RAM中有一块内存。
当您将此库包含到您的项目中(例如在 c++ 中)时,您必须添加有关此 DLL 中的函数的一些信息。
第一个选项:
您可以声明一些库函数的接口(然后您的链接器很高兴;))。
例如: __declspec(dllexport) int my_function(char *);
之后导出对象的名称在您的程序中完成(链接器作业;))...但是
该对象的名称取决于语言、编译器等等
第二个选项:
您可以向库的项目中添加链接器的一些信息(文件 *.def)。该文件有两个部分:LIBRARY 和 SECTIONS。 LIBRARY 是您的库的内部名称:
库 my_lib
在 EXPORTS 部分是可以从库中导出的符号。
出口
函数1
函数2
函数3
你可以看到,这个函数没有类型、形式参数等。当你包含这个库时,你没有任何关于函数的信息。
当你这样做(.def 文件)并编译你的lib,您有 .dll 和 .lib 文件。第二个文件可用于在执行时链接库。
如果您想检查此库中的导出,可以使用“Dependecny Walker”或“dumpbin”:
dumpbin my.dll /exports
接下来您可以加载该库:
第一个选项: __declspec(dllimport) int my_function(char *);
或
第二:HMODULE LoadLibrary(LPCSTR lpszLibName);
结论:使用导出可以创建更通用的库(但更复杂)
(抱歉我的英语很糟糕:/)
Imagine that:
You are a designer of library (DLL). You have to define what library must to do ... and after that you write it. Many process can use your functions from this DLL, there are one piece of memory in your RAM.
When you include this library to your project (for example in c++) you have to add some informations about functions in this DLL.
First option:
You can declare some interfaces of library functions (then your linker is happy ;) ).
For example: __declspec(dllexport) int my_function(char *);
After that names of exported objects are completed in your programme (linker job ;) )... but
Names of this objects depends on language, compiler, blah blah blah
Second option:
You add to the project of your library some informations to the linker (file *.def). That file has two sections: LIBRARY and SECTIONS. LIBRARY is internal name your lib:
LIBRARY my_lib
In EXPORTS section are symbols which can by exported from library.
EXPORTS
function1
function2
function3
You can see, this functions doesn't have types, formal parameters etc. When you include this lib, you don't have any information about function.
When you do this (.def file) and compile your lib, you have got .dll and .lib file. Second file can be use to link library in execution time.
If you want check exports in this library you can use "Dependecny Walker" or "dumpbin":
dumpbin my.dll /exports
Next you can load that library:
first option: __declspec(dllimport) int my_function(char *);
or
second: HMODULE LoadLibrary(LPCSTR lpszLibName);
conlusion: using exports can create more universal lib (but more complicated)
(sorry for my very bad english :/)