简体   繁体   English

帮助了解Makefile.in中的EXPORTS

[英]Help in understanding EXPORTS in Makefile.in

In the Makefile.in of an existing c++ project on linux (ubuntu), it has this: 在linux(ubuntu)上现有c ++项目的Makefile.in中,它具有以下内容:

EXPORTS     = \
        gtkmozembed.h \
        gtkmozembed_glue.cpp \
        gtkmozembed_internal.h

Can you please tell me what does EXPORTS mean? 您能告诉我出口是什么意思吗?

Thank you. 谢谢。

EXPORTS is just the name of a list of files. EXPORTS只是文件列表的名称。 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. EXPORTS中的.cpp文件可能意味着该文件包含用户必须编译并链接到其项目的框架代码。

Your example is from Firefox. 您的示例来自Firefox。 It's defined as: 定义为:

export:: $(EXPORTS) 
    $(INSTALL) -m 444 $^ $(PUBLIC_EXPORT_DIR)

Copying or installing files in Makefiles is a bit problematic. 在Makefiles中复制或安装文件有点问题。 Note that there is no dependency between the copy and its original. 请注意,副本与其原始副本之间没有依赖关系。

Imagine that: 想象一下:
You are a designer of library (DLL). 您是库(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. 许多进程可以通过此DLL使用您的函数,您的RAM中有一块内存。
When you include this library to your project (for example in c++) you have to add some informations about functions in this DLL. 当将此库包含到项目中时(例如,在c ++中),您必须在此DLL中添加有关函数的一些信息。

First option: 第一种选择:
You can declare some interfaces of library functions (then your linker is happy ;) ). 您可以声明一些库函数的接口(然后您的链接器很高兴;))。 For example: __declspec(dllexport) int my_function(char *); 例如:__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). 您将一些信息添加到链接器的库项目中(文件* .def)。 That file has two sections: LIBRARY and SECTIONS. 该文件有两个部分:LIBRARY和SECTIONS。 LIBRARY is internal name your lib: LIBRARY是您的库的内部名称:
LIBRARY my_lib 库my_lib
In EXPORTS section are symbols which can by exported from library. “导出”部分中的符号可以从库中导出。
EXPORTS 出口
function1 功能1
function2 功能2
function3 功能3

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. 您会看到,此函数没有类型,形式参数等。当包含此lib时,您将没有有关函数的任何信息。

When you do this (.def file) and compile your lib, you have got .dll and .lib file. 当您执行此操作(.def文件)并编译您的lib时,您将获得.dll和.lib文件。 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": 如果要在此库中检查导出,可以使用“ Dependecny Walker”或“ dumpbin”:
dumpbin my.dll /exports dumpbin my.dll / exports

Next you can load that library: 接下来,您可以加载该库:
first option: __declspec(dllimport) int my_function(char *); 第一个选项:__declspec(dllimport)int my_function(char *);
or 要么
second: HMODULE LoadLibrary(LPCSTR lpszLibName); 第二个:HMODULE LoadLibrary(LPCSTR lpszLibName);

conlusion: using exports can create more universal lib (but more complicated) 结论:使用导出可以创建更多的通用库(但更复杂)

(sorry for my very bad english :/) (对不起,我的英语很差:/)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM