Linking to C

Nick Sabalausky a at a.a
Tue Nov 2 23:25:17 PDT 2010


"scrappylildude" <sdl at yahoo.com> wrote in message 
news:iaqu6l$2sq5$1 at digitalmars.com...
> That's great--thanks Nick, Andrei.
>
> I tried it and it looks like I haven't configured something right.   I'm 
> building a sample
> project with my program, my utility class library and libraw.  I've added 
> the path to
> libraw_c_headers.d to dmd.conf, now that I don't have a -I switch any more 
> (using
> rdmd).
>
> When I use rdmd, something like my original error seems to have returned: 
> :(
>
> rdmd --build-only helloworld.d
>
> Undefined symbols:  "_D4hecl4base8HECLBase11__InterfaceZ", referenced 
> from:
> _D4hecl4base12__ModuleInfoZ in helloworld.d.old: symbol(s) not 
> foundcollect2: ld
> returned 1 exit status
> --- errorlevel 1
>
> My project is organized as follows:
> root/
>    stuff_i_made/
>        my project/
>            helloworld.d
>        my class library/
>            hecl*.d
>    stuff_I_didnt_make/
>        libraw/
>            lib/
>                libraw_r.a
>            src/
>                libraw_c_headers.d
>
> Using --dry-run seems to show everything except the libraw_r.a.  Since I 
> don't have a
> -L switch with rdmd, I assume this is the problem?
>

Oh that's right, I forgot you said you were linking against a static C lib. 
There's currently three bugs in RDMD relating to what you're doing here, two 
of them have patches though:

http://d.puremagic.com/issues/show_bug.cgi?id=3564
http://d.puremagic.com/issues/show_bug.cgi?id=4672
http://d.puremagic.com/issues/show_bug.cgi?id=4928

Until those get sorted out (or at least the first one, and then apply the 
patches from the other two), then yea, you'll probably have to work around 
it by just passing everything to dmd directly:

dmd "stuff_i_made/my project/helloworld.d" "stuff_i_made/my class 
library/hecl*.d" stuff_I_didnt_make/libraw/lib/libraw_r.a 
stuff_I_didnt_make/libraw/src/libraw_c_headers.d

If you're using D1, you could probably use xfbuild (don't have link offhand, 
but should be easy to google).





More information about the Digitalmars-d mailing list