Issues with workspace-d and code-d on Linux
Igor
stojkovic.igor at gmail.com
Fri Jul 27 18:39:52 UTC 2018
On Thursday, 26 July 2018 at 09:42:13 UTC, Laurent Tréguier wrote:
> On Wednesday, 25 July 2018 at 20:03:49 UTC, Igor wrote:
>> [...]
>> And so here I am, hoping that someone can explain how to set
>> everything up so I get Windows like experience while working
>> with VSCode on Linux (or some other editor).
>
> This extension enables debugging with GDB/LLDB :
> https://marketplace.visualstudio.com/items?itemName=webfreak.debug.
> Since you installed DMD and LDC using the install.sh script,
> you will need to manually set the `d.stdlibPath` value in
> VSCode's settings...
Thanks Laurent. It is working now. For future reference I will
write all steps here.
This guide assumes DMD is installed using the install script:
curl -fsS https://dlang.org/install.sh | bash -s dmd
~/dlang/install.sh install dmd
~/dlang/install.sh install ldc
If you want to permanently set PATH and other needed variables
you need to copy them from activate script of one of installed
compilers into your .profile file. If you are on KDE then it
should go in ~/.config/plasma-workspace/env/ldc.sh. This is how
my ldc.sh looks like since I have KDE and I want ldc compiler by
default:
# set PATH so it includes LDC compiler
if [ -d "$HOME/dlang/ldc-1.10.0" ] ; then
PATH="$HOME/dlang/ldc-1.10.0/bin${PATH:+:}${PATH:-}"
export PATH="$HOME/git/workspace-d/bin${PATH:+:}${PATH:-}"
export
LIBRARY_PATH="$HOME/dlang/ldc-1.10.0/lib${LIBRARY_PATH:+:}${LIBRARY_PATH:-}"
export
LD_LIBRARY_PATH="$HOME/dlang/ldc-1.10.0/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH:-}"
export DMD=ldmd2
export DC=ldc2
fi
After that install VSCode if it is not already installed. Open it
and go to Extensions tab (last icon on the left). Search for
"webfreak". You will see "D Language utility extension pack"
which contains all you need for the DLang development. In the
description you can see what individual plugins it installs and
what they do so if you choose you can only install some of them.
"D Programming Language (code-d)" is required for autocomplete
and "Native Debug" for debugging. Once you install that and
reload VSCode go to File-Preferences-Settings (Ctrl+,). In the
right part of the window, under User Settings you will see some
dlang settings are already added. Bellow them I also added this:
"d.dmdPath": "ldmd2",
"d.stdlibPath": [
"/home/igors/dlang/dmd-2.081.1/druntime/import",
"/home/igors/dlang/dmd-2.081.1/phobos"
],
First line is needed because I want to use LDC compiler. After
that you can open View-Command Pallete (Ctrl+Shift+P) and type
code-d and see all kind of commands related to it and one of them
should be "Create new project". This will init your project with
a single d code file and basic dub configuration for building it.
If at that point you press F5 you will be offered to add a GDB
(or LLDB if you have clang installed) configuration for
debugging. Once you do that you will get a launch.json file under
.vscode dir in your project and there you should add this line:
"preLaunchTask": "buildAndRun",
After that you should select Tasks-Configure Tasks and in the
drop down select dub: Run option. That will create a tasks.json
file for building and running your project. You should add this
line so launch.json can reference it:
"identifier": "buildAndRun",
If at this point you press F5 to debug your program it will be
built but debugger will probably report an error how it couldn't
find what to debug. You need to see where you program was build
(by default in the root of your project) and then put its name in
launch.json under target property. For example my project is
called dtest so I set it up like this:
"target": "./dtest",
At this point it should be clear what goes where and how it works
so you can now edit your json files and configure them to your
liking.
More information about the Digitalmars-d-ide
mailing list