You are right, thank you!


On Saturday, 12 May 2012 at 22:57:26 UTC, Jonathan M Davis wrote:
On Saturday, May 12, 2012 22:49:29 Shadow_exe wrote:
Faced with an interesting problem:
If I import std.sotsket in the main file (which I am passing a
parameter for the dmd), everything works, but if I import
std.sotsket in the include file I get this situation here:

main.d:
module test;

import  net.local_address;


void main(){
}

net/local_address.d:
module net.local_address;

import  std.socket;

the compiler says:
root@213:~/test# dmd test.d
test.o:(.data+0xc): undefined reference to
`_D3net13local_address12__ModuleInfoZ'
collect2: ld returned 1 exit status
--- errorlevel 1


How to deal with it?

You have to compile all of the modules. My guess is that all you did was

dmd -w main.d

and that won't work, because then you didn't compile net/local_address.d, which means that it's in not any of the object files being linked and so
naturally the linker is going to complain that it's undefined.

If you want the compiler to automatically find and compile all of the modules that you import in the one module that you give it, you need to use the tool rdmd. dmd itself works just like you'd expect from a C/C++ compiler (and the compilers in most languages actually) in that it won't compile the modules
that you don't tell it to.

- Jonathan M Davis


Reply via email to