error linking to my own custom module
torhu
no at spam.invalid
Tue Nov 10 20:14:21 PST 2009
On 11.11.2009 04:57, Sean Fennell wrote:
> I'm very green to D, just learning it now.
> I have a module that I wrote. Its pretty simple, just helper functions to get input from user as certain data types
> GetInt()
> GetString()
> GetChar()
> etc...
>
> I compiled the module using dmd -lib mymod.d which output mymod.a
>
> Now I've imported my module into ask.d to test it and I get the folliowing linking error when I try to compile:
>
> ask.o:(.data+0x4c): undefined reference to `_D4mymod12__ModuleInfoZ`
> My dir structure looks like this:
>
> project/
> ---ask.d
> ---lib/
> ------mymod.d
> ------mymod.a
>
> and my import line is:
>
> import lib.mymod;
>
> Anyone seen this before? Using linux dmd v2.036
>
> Thanks!
>
You have to hand all the files to the compiler, otherwise there will be
missing symbols when the compiler runs the linker.
Like this:
dmd ask lib/mymod
Compiling to a library first, like you did, will work too. But you have
to hand the compiler everything when you want to create the actual
executable:
dmd ask lib/mymod.a
There are build tools, like dsss, that will automate this for you.
More information about the Digitalmars-d-learn
mailing list