Import error

Steven Schveighoffer schveiguy at yahoo.com
Thu Nov 11 04:50:57 PST 2010


On Thu, 11 Nov 2010 07:44:22 -0500, Carlo <carlo.lucibello at gmail.com>  
wrote:

> Hi everyone,
> i'm having trouble with the statement import. Here is an example:
>
> //file ~/d/libtest.d
> int fun(int x){
>      return x;
> }
> //endfile
>
> //file ~/d/test.d
> import std.stdio;
> import libtest;
>
> void main(){
>      writeln(fun(2));
> }
> //endfile
>
>
> I issue the commands
> #cd ~/d
> #dmd test.d
>
> and i get the error
>
> test.d:(.text._Dmain+0x9): undefined reference to `_D7libtest3funFiZi'
> collect2: ld returned 1 exit status
> --- errorlevel 1
>
> I have no troubles with standard libraries, just mine's. I have the dmd  
> 2.0.50 compiler on a GNU/Linux 64bit system. Any idea?

dmd test.d libtest.d

"undefined reference" usually means it's a link error, meaning it can't  
find the code that implements that function.

-Steve


More information about the Digitalmars-d-learn mailing list