Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking to Static libraries

Tags:

d

Coming from a C/C++ background. What is the proper way to link a D static (or dynamic) library to a D .exe file? Can I simply "import" the module from the library and then link to the .lib file at compile time?

like image 260
Timothy Baldridge Avatar asked Oct 04 '10 21:10

Timothy Baldridge


People also ask

What is linking static library?

In computer science, a static library or statically-linked library is a set of routines, external functions and variables which are resolved in a caller at compile-time and copied into a target application by a compiler, linker, or binder, producing an object file and a stand-alone executable.

What happens when you link a static library?

Static linking increases the file size of your program, and it may increase the code size in memory if other applications, or other copies of your application, are running on the system. This option forces the linker to place the library procedures your program references into the program's object file.

Is static library linked?

Static libraries are just collections of object files that are linked into the program during the linking phase of compilation and are not relevant during runtime.

What does static linking do?

Static linking means that the code for all routines called by your program becomes part of the executable file. Statically linked programs can be moved to run on systems without the XL Fortran runtime libraries.


1 Answers

Yes, for static libs, but you also need to pass the library's sources or *.di files to the compiler via -I.

I think D does not have good (or any?) support for dynamic libs at present, though it is high on the todo list.

like image 71
Ellery Newcomer Avatar answered Feb 08 '23 20:02

Ellery Newcomer