Linker error with one particular function

Jacob Carlborg doob at me.com
Wed Aug 14 07:05:07 PDT 2013


On 2013-08-14 15:21, Gary Willoughby wrote:
> I have defined the following module:
>
> /**
>   * Module containing unit test helper functions for date time operations.
>   */
> module common.test.unit.datetime;
>
> /**
>   * Imports.
>   */
> import std.conv;
> import std.datetime;
>
> /**
>   * Return a unix timestamp.
>   *
>   * Params:
>   *     T = The return type of the unix timestamp.
>   *     A = Variadic argument type for args parameter.
>   *     args = Time arguments as specified by the DateTime struct.
>   *
>   * Reference:
>   *     $(LINK http://dlang.org/phobos/std_datetime.html#.DateTime)
>   */
> T getUnixTime(T, A...)(A args)
> {
>      return to!T(SysTime(DateTime(args)).toUnixTime());
> }
>
> But when i import it and use the getUnixTime function i get the
> following linker error:
>
> Undefined symbols for architecture x86_64:
>    "_D6common4test4unit8datetime12__ModuleInfoZ", referenced from:
>        _D5logic25generalstatisticprocessor12__ModuleInfoZ in main.o
>        _D5logic14eventprocessor12__ModuleInfoZ in main.o
>        _D5logic24devicestatisticprocessor12__ModuleInfoZ in main.o
> ld: symbol(s) not found for architecture x86_64
> collect2: ld returned 1 exit status
>
> Any idea why this is? If i comment out the getUnixTime function and put
> in other code it seems to import and work ok. Is it anything to do with
> the way i've written the function?

Have you compiled all the files? Show us the command you use to compile 
your code. Usually this is enough "rdmd main.d", where "main.d" is the 
file containing the main function.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list