Search code examples
linuxgcc

'dlltool' equivalent in Linux


In Windows, an executable called dlltool, given with GCC, is used to generate import library for a DLL file which is used for linking DLL files.

For example, libmylibrary.a for mylibrary.dll. But in Linux (i.e., Ubuntu) I haven't find any equivalent program like this. In gcc (both Windows and Linux), the -l options is used to link these import libraries.

So, is there such an application in Linux that can generate an import library for shared object (.so files)?


Solution

  • There are even easier way to do this. There is something called linker scripts, which is a text file similiar to .def file. Just write linker script on a text file, rename extension from .txt to .a and add lib before its name and then pass it as argument with -l command of the compiler or linker.

    An example of linker script is given below

    OUTPUT_FORMAT(elf32_i386)
    INPUT(/usr/lib/i386-linux-gnu/libssl3.so /usr/lib/i386-linux-gnu/libao.so.4)