Importing D libraries

Andrew Wiley wiley.andrew.j at gmail.com
Tue Jul 26 02:40:15 PDT 2011


On Tue, Jul 26, 2011 at 2:02 AM, Dainius (GreatEmerald)
<pastas4 at gmail.com>wrote:

> I must be missing something incredibly obvious here, but I can't find
> out what it is... I'm trying to build a very simple test program for
> LuaD, right now it simply imports the library. But it throws a linker
> error for some reason. Here's the program I'm trying to compile:
>
>    import std.stdio;
>    import luad.all;
>
>    int main()
>    {
>        readln();
>        return 0;
>    }
>
> This is what I use to compile it:
>
>    dmd -ILuaD LuaTest.d
>
> This is the error it gives me:
>
>    LuaTest.o:(.data+0x18): undefined reference to
> `_D4luad3all12__ModuleInfoZ'
>    collect2: ld returned 1 exit status
>    --- errorlevel 1
>
> I got LuaD by simply performing a git clone from here:
> https://github.com/JakobOvrum/LuaD
> Using Linux, DMD64 v2.053.
>

DMD will parse files you import, but won't generate output for them unless
you specify them on the command line. If you want it to generate code for
luad.all (which is what the linker says is missing), you need to compile
like this:
dmd -ILuaD LuaTest.d LuaD/luad/all.d
There are probably other files you need in LuaD, so you might try generating
a lib:
dmd -ILuaD -lib -ofLuaD.lib LuaD/luad/*.d [insert other paths as
appropriate]
Which you can then use like this:
dmd -ILuaD LuaTest.d LuaD.lib
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20110726/582ccdfe/attachment.html>


More information about the Digitalmars-d-learn mailing list