Thread overview
How do I correctly install packages for use with Visual Studio?
Oct 16, 2022
Decabytes
Oct 16, 2022
rikki cattermole
Oct 16, 2022
Mike Parker
Oct 16, 2022
matheus
Oct 16, 2022
Imperatorn
Oct 17, 2022
Decabytes
Oct 16, 2022
Mike Parker
Oct 17, 2022
JN
Oct 17, 2022
Guillaume Piolat
October 16, 2022

I'm trying to set up Visual Studio 2022 with Visual D, and I'm running into issues trying to get my project to build correctly. It's a double whammy because I've never used Visual Studio before (Just an Emacs Guy), but I need to debug my D programming and according to the documentation this is my only option on Windows.

I'm confused at what/where exactly D expect files to be for them to considered "installed". I'm using raylib-d.

  1. My "compile and debug" and "compile and run" options both include "-lraylib" I've also tried just "-lib raylib"

  2. I have the raylib source file located in my C:\D\dmd2\src

  3. I have "-I%@P%....\src\raylib" in my sc.ini file located at C:\D\dmd2\windows\bin.

  4. I even have raylib.dll and raylib.lib in the same directory as my d source file.

Despite this when I hit the Start button in Visual Studio I get this error

Building x64\Debug\chip8.exe...
chip8.d(4): Error: unable to read module `raylib`
chip8.d(4):        Expected 'raylib.d' or 'raylib\package.d' in one of the following import paths:
import path[0] = C:\D\dmd2\windows\bin\..\..\src\phobos
import path[1] = C:\D\dmd2\windows\bin\..\..\src\druntime\import
import path[2] = C:\D\dmd2\windows\bin\..\..\src\gtkd
import path[3] = C:\D\dmd2\windows\bin\..\..\src\raylib

But I do have a package.d located in C:\D\dmd2\src\raylib\package.d. Does anyone know what I did wrong?

October 17, 2022
On 17/10/2022 12:09 AM, Decabytes wrote:
> I'm trying to set up Visual Studio 2022 with Visual D, and I'm running into issues trying to get my project to build correctly. It's a double whammy because I've never used Visual Studio before (Just an Emacs Guy), but I need to debug my D programming and according to the [documentation](https://wiki.dlang.org/Debuggers) this is my only option on Windows.

You don't need to develop with Visual Studio for native executables to debug using it.

Build your program with debug symbols (-g) and open the executable as a project. You can then debug it with source code support.
October 16, 2022

On Sunday, 16 October 2022 at 11:09:31 UTC, Decabytes wrote:

>

Building x64\Debug\chip8.exe...
chip8.d(4): Error: unable to read module raylib
chip8.d(4): Expected 'raylib.d' or 'raylib\package.d' in one of the following import paths:
import path[0] = C:\D\dmd2\windows\bin....\src\phobos
import path[1] = C:\D\dmd2\windows\bin....\src\druntime\import
import path[2] = C:\D\dmd2\windows\bin....\src\gtkd
import path[3] = C:\D\dmd2\windows\bin....\src\raylib

But I do have a package.d located in  C:\D\dmd2\src\raylib\package.d. Does anyone know what I did wrong?

Your import paths are wrong. This, for example:

>

import path[3] = C:\D\dmd2\windows\bin....\src\raylib

The path should be

C:\D\dmd2\windows\bin....\src\

Ditto for gtkd looks like.

October 16, 2022
On Sunday, 16 October 2022 at 11:09:31 UTC, Decabytes wrote:
> I'm trying to set up Visual Studio 2022 with Visual D, and I'm running into issues trying to get my project to build correctly. It's a double whammy because I've never used Visual Studio before (Just an Emacs Guy), but I need to debug my D programming and according to the [documentation](https://wiki.dlang.org/Debuggers) this is my only option on Windows.

I don't know if anything changed significantly, but I used to debug on Windows with WinDbg without any IDE.

Maybe this is useful: https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-download-tools

Matheus.
October 16, 2022

On Sunday, 16 October 2022 at 11:09:31 UTC, Decabytes wrote:

>

I'm confused at what/where exactly D expect files to be for them to considered "installed".

D doesn't expect them to be anywhere. By default, the compiler will search relative to the current working directory, on any paths configured in dmd's config file, and on any paths you (or your IDE) give it via -I on the command line.

I strongly recommend against keeping libraries in the dmd source directory. You'll have to copy them over again on every new compiler install.

If Visual D doesn't yet support dub (I've not used it in a long while, so I don't know), then it's probably best to set up a common directory somewhere on your system. Just make sure not to put the package directory (e.g., in src/raylib, raylib is the package directory) on the import path, but the root source directory.

You'll probably want to keep any compiled library binaries on a common path, too, so that you can configure that in the IDE settings.

October 16, 2022

On Sunday, 16 October 2022 at 11:42:04 UTC, matheus wrote:

>

On Sunday, 16 October 2022 at 11:09:31 UTC, Decabytes wrote:

>

I'm trying to set up Visual Studio 2022 with Visual D, and I'm running into issues trying to get my project to build correctly. It's a double whammy because I've never used Visual Studio before (Just an Emacs Guy), but I need to debug my D programming and according to the documentation this is my only option on Windows.

I don't know if anything changed significantly, but I used to debug on Windows with WinDbg without any IDE.

Maybe this is useful: https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-download-tools

Matheus.

I also highly recommend WinDbg Preview

https://apps.microsoft.com/store/detail/windbg-preview/9PGJGD53TN86

October 17, 2022
On Sunday, 16 October 2022 at 11:42:04 UTC, matheus wrote:
> On Sunday, 16 October 2022 at 11:09:31 UTC, Decabytes wrote:
>> I'm trying to set up Visual Studio 2022 with Visual D, and I'm running into issues trying to get my project to build correctly. It's a double whammy because I've never used Visual Studio before (Just an Emacs Guy), but I need to debug my D programming and according to the [documentation](https://wiki.dlang.org/Debuggers) this is my only option on Windows.
>
> I don't know if anything changed significantly, but I used to debug on Windows with WinDbg without any IDE.
>
> Maybe this is useful: https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-download-tools
>
> Matheus.

After some fiddling I got WinDBG up and running. It's not perfect (no
syntax highlighting for D is a bummer, but at least I can do some debugging now. Thank you
October 17, 2022

On Sunday, 16 October 2022 at 11:09:31 UTC, Decabytes wrote:

>

It's a double whammy because I've never used Visual Studio before (Just an Emacs Guy), but I need to debug my D programming and according to the documentation this is my only option on Windows.

I am using Visual Studio Code with code-d plugin and using the standard C++ debugger. Seems to work well enough. Some D-specific constructs like AA look weird at times, but breakpoints work, shows me values of variables, callstacks.

October 17, 2022

On Sunday, 16 October 2022 at 11:09:31 UTC, Decabytes wrote:

>

I'm trying to set up Visual Studio 2022 with Visual D, and I'm running into issues trying to get my project to build correctly.

Some recommendation to use Visual Studio:

  • tutorial for installation here: https://p0nce.github.io/d-idioms/#Installing-Dlang-on-Windows

  • then generate a Visual Studio solution with:

       dub generate visuald                        # default
       dub generate -a x86 visuald --compiler dmd  # for DMD, x86 arch
       dub generate -a x86_64 visuald -c conf      # x86_64 arch, DUB configuration "conf"
       dub generate visuald --combined             # single VisualD project with all deps
    
  • if you use libraries that work with DUB they should come with static libs, or have dynamic loaders instead. Building .lib files yourself is just more annoying, and you will have to do it for each system you want to support