On Wednesday, 3 January 2018 at 12:21:28 UTC, tipdbmp wrote:
// C:\libs\my_module.d
module my_module;
void foo() {}

// main.d
module main;
import my_module;

void main() {
    foo();
}

Running dmd with:
    dmd -IC:\libs main.d my_module.d

I get:
Error: module my_module is in file 'my_module.d' which cannot be read
    import path[0] = C:\libs
import path[1] = path\to\dmd\D\dmd2\windows\bin\..\..\src\phobos import path[2] = path\to\dmd\D\dmd2\windows\bin\..\..\src\druntime\import

As has already been mentioned, the -I is not used for command-line files. Just compiling (-c option) shows that the -I is enough for DMD to find the import file:

dmd -c main.d -Ic:\libs

successfully compiles main.d into main.obj

To do a full compile and link of main without compiling my_module.d each time:

C:\libs>dmd -lib -ofmy_module.lib my_module.d

creates "my_module.lib". Then use it to link with in main.d compile/link:

C:\code\d\forum>dmd main.d -Ic:\libs -Llib c:\libs\my_module
OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Warning 9: Unknown Option : NOILIB


main.exe is created even though there is a mysterious warning.

Reply via email to