.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

相关文章

电脑提示d3dx11_43.dll缺失怎么办? DLL文件丢失的多种修复教程

《电脑提示d3dx11_43.dll缺失怎么办?DLL文件丢失的多种修复教程》在使用电脑玩游戏或运行某些图形处理软件时,有时会遇到系统提示“d3dx11_43.dll缺失”的错误,下面我们就来分享超... 在计算机使用过程中,我们可能会遇到一些错误提示,其中之一就是缺失某个dll文件。其中,d3dx11_4

游戏闪退弹窗提示找不到storm.dll文件怎么办? Stormdll文件损坏修复技巧

《游戏闪退弹窗提示找不到storm.dll文件怎么办?Stormdll文件损坏修复技巧》DLL文件丢失或损坏会导致软件无法正常运行,例如我们在电脑上运行软件或游戏时会得到以下提示:storm.dll... 很多玩家在打开游戏时,突然弹出“找不到storm.dll文件”的提示框,随后游戏直接闪退,这通常是由于

C++中detach的作用、使用场景及注意事项

《C++中detach的作用、使用场景及注意事项》关于C++中的detach,它主要涉及多线程编程中的线程管理,理解detach的作用、使用场景以及注意事项,对于写出高效、安全的多线程程序至关重要,下... 目录一、什么是join()?它的作用是什么?类比一下:二、join()的作用总结三、join()怎么

java中反射Reflection的4个作用详解

《java中反射Reflection的4个作用详解》反射Reflection是Java等编程语言中的一个重要特性,它允许程序在运行时进行自我检查和对内部成员(如字段、方法、类等)的操作,本文将详细介绍... 目录作用1、在运行时判断任意一个对象所属的类作用2、在运行时构造任意一个类的对象作用3、在运行时判断

python常用的正则表达式及作用

《python常用的正则表达式及作用》正则表达式是处理字符串的强大工具,Python通过re模块提供正则表达式支持,本文给大家介绍python常用的正则表达式及作用详解,感兴趣的朋友跟随小编一起看看吧... 目录python常用正则表达式及作用基本匹配模式常用正则表达式示例常用量词边界匹配分组和捕获常用re

Java 继承和多态的作用及好处

《Java继承和多态的作用及好处》文章讲解Java继承与多态的概念、语法及应用,继承通过extends复用父类成员,减少冗余;多态实现方法重写与向上转型,提升灵活性与代码复用性,动态绑定降低圈复杂度... 目录1. 继承1.1 什么是继承1.2 继承的作用和好处1.3 继承的语法1.4 子类访问父类里面的成

qt5cored.dll报错怎么解决? 电脑qt5cored.dll文件丢失修复技巧

《qt5cored.dll报错怎么解决?电脑qt5cored.dll文件丢失修复技巧》在进行软件安装或运行程序时,有时会遇到由于找不到qt5core.dll,无法继续执行代码,这个问题可能是由于该文... 遇到qt5cored.dll文件错误时,可能会导致基于 Qt 开发的应用程序无法正常运行或启动。这种错

电脑提示xlstat4.dll丢失怎么修复? xlstat4.dll文件丢失处理办法

《电脑提示xlstat4.dll丢失怎么修复?xlstat4.dll文件丢失处理办法》长时间使用电脑,大家多少都会遇到类似dll文件丢失的情况,不过,解决这一问题其实并不复杂,下面我们就来看看xls... 在Windows操作系统中,xlstat4.dll是一个重要的动态链接库文件,通常用于支持各种应用程序

SpringBoot 中 CommandLineRunner的作用示例详解

《SpringBoot中CommandLineRunner的作用示例详解》SpringBoot提供的一种简单的实现方案就是添加一个model并实现CommandLineRunner接口,实现功能的... 目录1、CommandLineRunnerSpringBoot中CommandLineRunner的作用

电脑提示Winmm.dll缺失怎么办? Winmm.dll文件丢失的多种修复技巧

《电脑提示Winmm.dll缺失怎么办?Winmm.dll文件丢失的多种修复技巧》有时电脑会出现无法启动程序,因为计算机中丢失winmm.dll的情况,其实,winmm.dll丢失是一个比较常见的问... 在大部分情况下出现我们运行或安装软件,游戏出现提示丢失某些DLL文件或OCX文件的原因可能是原始安装包