Yes thank you. That cleared this up.
On Thursday, 15 March 2012 at 22:08:18 UTC, H. S. Teoh wrote:
On Thu, Mar 15, 2012 at 09:16:45PM +0100, Chris Pons wrote:
Ok, I've actually run into another problem. I've decided to
use a
static library, since my project is small. I have added the
path to
the static library's .lib file in my project properties, just
like
with derelict2. However, I'm not sure how to use import
properly.
The import statement *always* works with D files. Well,
technically, you
can use a .di file generated by the compiler for your library,
but it's
basically a reduced form of the library D code. But in either
case, you
need to import the library D (or Di) file, not the .lib file.
The compiler itself doesn't even care about .lib files until it
has
finished compilation and moved on to the linking stage.
The library in question is in location (relative to my project)
Libraries/Math/math.lib.
If a module in math.lib is matrix, i've tried import
declarations
like:
import Libraries.Math.math.matrix; //probably very wrong
It's correct, albeit a bit ugly. To alleviate the ugliness, you
can tell
the compiler where the "root" directory for the library is
supposed to
be. For example, if you invoked dmd with -ILibraries/Math, then
you'll
be able to say:
import math.matrix;
and the compiler will know to look for
Libraries/Math/math/matrix.d.
[...]
This just lead me to believe that import matrix or import
math.matrix
should work.
Correct. Provided you specify the right -I option to the
compiler.
Am I wrong in assuming that the library contains the D code I
need to
use? So I would not be trying to import the .d file I used to
construct the static library?
[...]
The .lib file contains the *compiled* form of the library,
which is no
longer D code but machine code. So it can't be used with
import. The
import statement needs either the original library .d file, or
the
reduced .di generated by the compiler's -H option.
Hope this helps.
T