Search code examples
visual-studio-2012windows-7d

VisualD. Using external .lib


I am developing a project under Visual D. In solution I have one library project and one executable project. The question is how to link library project (to use modules from there) in executable project?

I tried to add library search path in project settings but that didn't take effect and compiler still wrote that error:

Error: module TestObject is in file 'Library\Core\TestObject.d' which cannot be read    D:\dev\projects\d\MySolution\Executable\main.d

Update 1 After some experiments, I discovered that problem is with compiler linker. I installed Xamarin Studio, added lib and executable projects, checked lib project as dependency for exectutable project, Xamarin Studio found (!!!) modules and namespaces from lib project, but compiler still wrote that stupid error. In Xamarin build log full qualified path to lib binary is present. (For reference, I am using Windows 7 x86)

Update 2 I pushed my project to GitHub, if you want to try to compile it - you're welcome.

Update 3 I already have tested compilation in MonoDevelop on fresh Ubuntu 13.10, and there is still presents that error. I think that maybe my problem with orginizing file structure or project structure...


Solution

  • I discovered that problem is with file structure. For some strange reason, in D you can not create nested projects with same module name like

    Core\MyClass.d:

    module Core.MyClass;
    
    class MyClass {
        //some stuff
    }
    

    and then to use it like:

    import Core.MyClass;
    

    because when you link a lib, it namespace will mixin in your global namespace, but module structure will not be followed. Will be followed file structure like module structure. This happens on all compilers (dmd, dmd2, ldc2, gdc). And this is very strange, because C# or ActionScript allow this and this is normal logic. Any ideas how to organize some structure like below?

    import Root.Sub.Target;