[Issue 281] New: dmd generates the object code ld cannot link when working with templates
Sean Kelly
sean at f4.ca
Thu Aug 10 08:07:03 PDT 2006
d-bugmail at puremagic.com wrote:
>
> It compiles fine, but ld generates following errors:
>
> [tbolsh]$ dmd TestBoxer
> gcc TestBoxer.o -o TestBoxer -m32 -lphobos -lpthread -lm
> TestBoxer.o(.gnu.linkonce.t_D3std5boxer27__T5unboxTC9TestBoxer4TestZ5unboxFS3std5boxer3BoxZC9TestBoxer4Test+0x1a):
> In function
> `_D3std5boxer27__T5unboxTC9TestBoxer4TestZ5unboxFS3std5boxer3BoxZC9TestBoxer4Test':
> TestBoxer.d: undefined reference to `_assert_3std5boxer'
This is a known issue with DMD. Basically, Phobos is built in release
mode so these functions are not generated in the std.boxer object file.
When you import std.boxer into your app and build with -debug set, the
template code for std.boxer is built into the app itself, with
references to the code it thinks is in Phobos (but isn't).
Since DMD always links against phobos.lib regardless of whether the app
has -debug set, what I do for pure template modules like std.boxer is
build them with -debug set and link that code into the lib. This makes
the assert code and such available if it's needed, and if not it simply
won't be used. It's not ideal, but it's a reasonable workaround until
something is done about this issue.
Sean
More information about the Digitalmars-d-bugs
mailing list