.dll.a 和.la 文件的作用

2024-03-14 01:08
文章标签 作用 dll la

本文主要是介绍.dll.a 和.la 文件的作用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1. dll.a 其实是MinGW下的DLL文件的imp-lib (Import Library)

 

.dll.a文件的最初用意其实是MinGW下的DLL文件的imp-lib (Import Library),即与VC下DLL文件附带了一个引入库.lib类似。在VC下编程,当要使用DLL文件时,在开发时必须要有.lib文件才能链接通过。.dll.a文件就是这样的作用。

 

但是,MinGW/Cygwin确提供了直接与.dll文件链接的作用,就是可以不需要imp-lib库文件,只要DLL文件存在,也可以链接成功。这样就导致.dll.a文件似乎不是那么有用了。在很多场合下,可以不需要.dll.a文件了。但是有几个例外情况,来自于RedHat的官方描述。(Reference)

 

2. Building an Import Library (Reference)

Sun's distribution of the Java Development Kit includes a file in the lib/ directory calledjvm.lib. This is a Win32 static library against which compilers like VC++ can link. However,gcc can't handle the .lib file (as far as I know), so we need to create a UNIX-y import library (a.a file) against which we can link.

In order to do this, I tried to come up with the minimal set of JNI functions that need to be visible to native programs in order to link. I believe the following list of functions is minimal. Intuitively, it's because these are the only functions that can be called without having a reference to a pointer returned from one of these three functions:

  • JNI_CreateJavaVM
  • JNI_GetDefaultJavaVMInitArgs
  • JNI_GetCreatedJavaVMs

Next, we'll create a DLL exports file to use with dlltool to build an import library. In order to do that, we'll export the symbols for the functions using the Pascal calling convention. (The numbers after the '@' sign indicate how many bytes need to be allocated on the stack for arguments.)

Here are the contents of the file:

EXPORTS
JNI_CreateJavaVM@12
JNI_GetDefaultJavaVMInitArgs@4
JNI_GetCreatedJavaVMs@12

By convention, DLL exports files are given the extension .def, so we'll save this file in our directory with the namejvm.def.

Now, we need to generate our import library. We can do that with dlltool, as follows:

dlltool --input-def jvm.def --kill-at --dllname jvm.dll --output-lib libjvm.dll.a
Naming the output file libjvm.dll.a will allow gcc to recognize it as a library named jvm. The .dll.a suffix indicates (by convention) that it is an import library, rather than a static library (which would simply be named libjvm.a, again by convention).

All of that said, I believe the libjvm.dll.a file would be standard across installations. So if you don't feel like building your own, you may be able to usemine. (If you try it, pleaselet me know whether it works.)

Note that in the dlltool argument list, we don't specify where jvm.dll is located, or which one we want to use. The name jvm.dll is what is embedded inlibjvm.dll.a (and hence in executables we will compile against it); no content fromjvm.dll is used. When a running program sees a reference to jvm.dll, it will attempt to locate it at that time. (Each Sun JVM has its ownjvm.dll, so we can take advantage of this feature to select which VM implementation to use at runtime.)

3. la 文件

原文地址:http://stackoverflow.com/questions/1238035/libtool-what-la-file-is-for

la file is textual file that includes description of library. It allows libtool create platform independent names. 即 la  文件是纯文本文件,只存放真实library的名字和路径。

For example, libfoo goes to:

Under linux:

/lib/libfoo.so       # symlink to shared object
/lib/libfoo.so.1     # symlink to shared object
/lib/libfoo.so.1.0.1 # shared object
/lib/libfoo.a        # static library
/lib/libfoo.la       # libtool library


Under cygwin:

/lib/libfoo.dll.a    # import library
/lib/libfoo.a        # static library
/lib/libfoo.la       # libtool library
/bin/cygfoo_1.dll    # dll


Under windows mingw:

/lib/libfoo.dll.a    # import library
/lib/libfoo.a        # static library
/lib/libfoo.la       # libtool library
/bin/foo_1.dll       # dll


So.. libfoo.la is the only file that preserved between platforms by libtool allowing to understand, what happens with:

  • library dependencies
  • actual file names
  • library version and revision

Without depending on specific platform implementation of libraries.

 

这篇关于.dll.a 和.la 文件的作用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/806804

相关文章

Android fill_parent、match_parent、wrap_content三者的作用及区别

这三个属性都是用来适应视图的水平或者垂直大小,以视图的内容或尺寸为基础的布局,比精确的指定视图的范围更加方便。 1、fill_parent 设置一个视图的布局为fill_parent将强制性的使视图扩展至它父元素的大小 2、match_parent 和fill_parent一样,从字面上的意思match_parent更贴切一些,于是从2.2开始,两个属性都可以使用,但2.3版本以后的建议使

【LabVIEW学习篇 - 21】:DLL与API的调用

文章目录 DLL与API调用DLLAPIDLL的调用 DLL与API调用 LabVIEW虽然已经足够强大,但不同的语言在不同领域都有着自己的优势,为了强强联合,LabVIEW提供了强大的外部程序接口能力,包括DLL、CIN(C语言接口)、ActiveX、.NET、MATLAB等等。通过DLL可以使用户很方便地调用C、C++、C#、VB等编程语言写的程序以及windows自带的大

maven发布项目到私服-snapshot快照库和release发布库的区别和作用及maven常用命令

maven发布项目到私服-snapshot快照库和release发布库的区别和作用及maven常用命令 在日常的工作中由于各种原因,会出现这样一种情况,某些项目并没有打包至mvnrepository。如果采用原始直接打包放到lib目录的方式进行处理,便对项目的管理带来一些不必要的麻烦。例如版本升级后需要重新打包并,替换原有jar包等等一些额外的工作量和麻烦。为了避免这些不必要的麻烦,通常我们

未来工作趋势:零工小程序在共享经济中的作用

经济在不断发展的同时,科技也在飞速发展。零工经济作为一种新兴的工作模式,正在全球范围内迅速崛起。特别是在中国,随着数字经济的蓬勃发展和共享经济模式的深入推广,零工小程序在促进就业、提升资源利用效率方面显示出了巨大的潜力和价值。 一、零工经济的定义及现状 零工经济是指通过临时性、自由职业或项目制的工作形式,利用互联网平台快速匹配供需双方的新型经济模式。这种模式打破了传统全职工作的界限,为劳动

Science|癌症中三级淋巴结构的免疫调节作用与治疗潜力|顶刊精析·24-09-08

小罗碎碎念 Science文献精析 今天精析的这一篇综述,于2022-01-07发表于Science,主要讨论了癌症中的三级淋巴结构(Tertiary Lymphoid Structures, TLS)及其在肿瘤免疫反应中的作用。 作者类型作者姓名单位名称(中文)通讯作者介绍第一作者Ton N. Schumacher荷兰癌症研究所通讯作者之一通讯作者Daniela S. Thomm

j2EE通用jar包的作用

原文:http://blog.sina.com.cn/s/blog_610901710101kx37.html IKIKAnalyzer3.2.8.jar // 分词器 ant-junit4.jar // ant junit antlr-2.7.6.jar // 没有此包,hibernate不会执行hql语句。并且会报NoClassDefFoundError: antlr

什么是dll

DLL的概念        DLL(Dynamic Link Library)文件为动态链接库文件,又称“应用程序拓展”,是软件文件类型。在Windows中,许多应用程序并不是一个完整的可执行文件,它们被分割成一些相对独立的动态链接库,即DLL文件,放置于系统中。当我们执行某一个程序时,相应的DLL文件就会被调用。一个应用程序可使用多个DLL文件,一个DLL文件也可能被不同的应用程序使

【vue3|第28期】 Vue3 + Vue Router:探索路由重定向的使用与作用

日期:2024年9月8日 作者:Commas 签名:(ง •_•)ง 积跬步以致千里,积小流以成江海…… 注释:如果您觉在这里插入代码片得有所帮助,帮忙点个赞,也可以关注我,我们一起成长;如果有不对的地方,还望各位大佬不吝赐教,谢谢^ - ^ 1.01365 = 37.7834;0.99365 = 0.0255 1.02365 = 1377.4083;0.98365 = 0.0006 说

请解释Java Web应用中的前后端分离是什么?它有哪些好处?什么是Java Web中的Servlet过滤器?它有什么作用?

请解释Java Web应用中的前后端分离是什么?它有哪些好处? Java Web应用中的前后端分离 在Java Web应用中,前后端分离是一种开发模式,它将传统Web开发中紧密耦合的前端(用户界面)和后端(服务器端逻辑)代码进行分离,使得它们能够独立开发、测试、部署和维护。在这种模式下,前端通常通过HTTP请求与后端进行数据交换,后端则负责业务逻辑处理、数据库交互以及向前端提供RESTful