Importing problems
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Feb 13 10:40:49 PST 2013
On Wed, Feb 13, 2013 at 06:57:52PM +0100, Korey Peters wrote:
> Thanks for your response, H.S.Teoh.
>
> On Wednesday, 13 February 2013 at 17:47:09 UTC, H. S. Teoh wrote:
> >You need to specify both files on the command line, so that the
> >linker
> >knows where to find everything:
> >
> > rdmd sample.d sample_a.d
> >
>
> Running this from the command line produces (exactly?) the same
> error...
>
> me at ubuntu:~/src$ rdmd sample.d sample_a.d
> /tmp/.rdmd-1000/rdmd-sample.d-94E53075E2E84D963426A11F2B81FDED/objs/sample.o:
> In function `_Dmain':
> sample.d:(.text._Dmain+0xa): undefined reference to
> `_D8sample_a1A7__ClassZ'
> collect2: error: ld returned 1 exit status
> --- errorlevel 1
>
> I tried swapping the order of the file names, but that didn't help.
>
> >But before you can actually use the stuff in the other file, that
> >other file needs to be compiled as well (the 'import' only imports
> >declarations; it doesn't actually compile the declared code), and it
> >needs to be included in the linking stage so that all references
> >between the source files can be linked properly.
>
> Ah. I thought that the purpose of "rdmd" (as opposed to "dmd") was to
> link the files automatically. Thanks.
Actually, you're right, rdmd is supposed to automatically link all
dependent files. I just tried your code in my environment (Linux 64-bit,
git HEAD) and I didn't see this problem. I wonder if it's a bug that has
since been fixed?
Maybe you can try inserting this line into sample_a.d:
module sample_a;
I'm not sure if that will help, but just trying to narrow down the
problem a bit.
T
--
Give me some fresh salted fish, please.
More information about the Digitalmars-d-learn
mailing list