Thread overview
Working with Modules
Dec 28, 2016
pineapple
December 28, 2016
I am just starting up with dmd and code::blocks. Generally I have as my project structure something like this (sorry if your forum doesn't format this nicely, use the '-'es for directory nesting):

ProjectA
   -SubProject1
   -SubProject2
ProjectB
   -SubProject1
   -SubProjectB
HopefullySomeDProject
   -main.d
Libraries
   -C
     --CLibrary1
   -CPP
     --CPPLibrary1
   -CSharp
     --CSharpLibrary1
   -D
     --HopefullySomeDLibrary
        ---test.d
Workspaces
   -csharp.sln
   -mydproject.workspace

But it seems the D module system isn't playing nice with this setup. I keep getting this error:

||=== Build: Debug in tester (compiler: Digital Mars D Compiler) ===|
tester.d|4|Error: module test is in file 'test.d' which cannot be read|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

Unfortunately, neither code::blocks nor D's resources are really giving me any insight how I can make such a file structure work for me. Does D prefer more of a hierarchical structure where all libraries have to be in subdirectories? If so, how do people usually disembody the libraries from the actual projects?


December 28, 2016
The code...

tester.d

module main;

import std.stdio;
import test; <---dmd choking here.

int main(string[] args)
{
    writefln("Hello World\n");
    writefln(add(a, b));
    return 0;
}


test.d

module test;

int add(int a, int b)
{
    return a + b;
}
December 28, 2016
On Wednesday, 28 December 2016 at 02:08:44 UTC, Guy Asking a Question wrote:
> import test; <---dmd choking here.

You will need to use the -I option of dmd/rdmd to inform the compiler of where your `HopefullySomeDLibrary` directory is located, as well as any other places you will want to import modules from.

If you're using another compiler, it should have a similar option. (Though I can't speak from experience.)

December 28, 2016
On Wednesday, 28 December 2016 at 02:12:32 UTC, pineapple wrote:
> On Wednesday, 28 December 2016 at 02:08:44 UTC, Guy Asking a Question wrote:
>> import test; <---dmd choking here.
>
> You will need to use the -I option of dmd/rdmd to inform the compiler of where your `HopefullySomeDLibrary` directory is located, as well as any other places you will want to import modules from.
>
> If you're using another compiler, it should have a similar option. (Though I can't speak from experience.)

Thanks. That did the trick.