Template name undefined when import from "library" target.

Elfstone elfstone at yeah.net
Sat Apr 16 11:45:38 UTC 2022


I'm building my first program with dub. It appears I can import 
and use a struct from a "library". But the template struct is 
undefined unless I change the target type to "sourceLibrary".

The sources are like this:

     // library ////////////////
     // shapes.d
     module core.shapes;

     struct triangle
     {
     }

     // math.d
     module core.math;
     import std.stdio;
     struct MATRIX(T, int R, int C)
     {
     }

     // package.d

     module core;

     public
     {
         import core.math;
         import core.shapes;
     }
     /////////////

     // executable //////////////////

     import std.stdio;
     import core.math;
     import core.shapes;
     int main(string[] argv)
     {
         triangle t;
         MATRIX!(float, 4, 4) a;
         writeln(t);
         return 0;
     }

     // dub.sdl
     targetType "none"
     dependency ":example" version="*"

     subPackage {
         name "core"
         targetType "library"
         sourcePaths "core"
         importPaths "."
     }

     subPackage {
         name "example"
         targetType "executable"
         sourceFiles "example/main.d"
         importPaths "example"
         dependency "proj:core" version="*"
     }


I get Error: template instance `MATRIX!(float, 4, 4)` template 
`MATRIX` is not defined

What am I doing wrong here?




More information about the Digitalmars-d-learn mailing list