help understanding import libraries

Jesse Phillips jessekphillips+D at gmail.com
Fri Aug 19 09:38:01 PDT 2011


maarten van damme Wrote:

> the compiler flags I needed to add was -I for every src directory and -L for
> the lib file. The problem with that was that those files in the src dir
> don't declare the functions but also define them. They are the real source
> code files so I didn't understand why the -L flag was necessary. I never
> experimented further though :)

The process of creating an executable goes from generating machine code from source to linking the machine code for execution, as you know. The -I flag is the compiler import/include directory while -L is flags passed to the linker. That so while you may have complete source code in the import directory the compiler is only looking at the declaration and does not compile the files, it then informs the linker where the symbols can be found from the information you provide after the -L flag.

If you wanted (and didn't run out of command line characters) you could list all .d files in every library you are using and have dmd compile everything for you. Then the -L would not be required.


More information about the Digitalmars-d-learn mailing list