Installing dmd

Georg Wrede georg.wrede at iki.fi
Sun Mar 1 10:31:45 PST 2009


Adam D. Ruppe wrote:
> On Sun, Mar 01, 2009 at 06:56:50PM +0200, Georg Wrede wrote:
>> Ever since stone age, one's PATH contains ~/bin for one's own binaries. 
>> I believe this is with all Linux distros, and IIRC on Solaris. Probably 
>> on OSX too. The ~/bin isn't created for you, but that's the canonical 
>> place for the small dmd invocators.
> 
> Yah, that's what I use.
> 
>> I was just trying to figure out what the INSTALL.TXT should say about 
>> that. Somehow /usr/local/bin would seem the right place, but it doesn't 
>> usually contain other than executables, and certainly not subdirectories.
>>
>> So looks like the dmd tree has to be put somewhere else.
> 
> Qt installs itself to /usr/local/Trolltech/Qt-4.version with bin, lib, include,
> etc. as subdirectories in there.
> 
> It looks like Java and Mono do the same if you manually install them.
> 
> Something similar seems like a pretty good choice here too. Maybe:
> /usr/local/digitalmars/d1 and /d2

That looks good!

>> Only problem is that subdirectories of /usr/local/bin aren't in the 
>> path, so one would have to create here the starter scripts you've done.
>>
>> Any ideas?
> 
> I think putting the subdirs in /usr/local/whatever is the best option -
> it leads to easy installation and also easy uninstallation (though why
> would you do that??? :P)
> 
> Once there, you can use helper scripts (or symlinks) in /usr/local/bin,
> or adjust your PATH.

Well, symlinks directly to dmd executable don't work, because dmd 
doesn't then have access to its own name, which it needs to find 
everything in the tree. And adding to path would require that you rename 
all the different dmd compilers with different names, which is too much 
work, and confusing.

So, depending on, if one wants to have access to one dmd version at a 
time, or if one wants to compile even simultaneously (like in two 
windows) with different dmd versions, there are about two choices.

Let's assume one has ended up having

$ ls /usr/local/digitalmars
dmd2025 dmd1040

Then either

A:

create a symlink
$ cd
$ ln -s /usr/local/digitalmars/dmd2025 dmd

Now edit your ~/.bash_profile to contain

export PATH=$PATH:~/dmd/linux/bin

And everything should work the next time you login.

Once you're done with dmd2025 and want to use dmd1040 simply do

$ cd
$ rm dmd
$ ln -s /usr/local/digitalmars/dmd1040 dmd

and you're ready to use the old version.


OR if you want to use both new and old all the time, then

B:

edit your ~/.bashrc to contain the following lines

alias dmd1=/usr/local/digitalmars/dmd1040/linux/bin/dmd
alias dmd2=/usr/local/digitalmars/dmd2025/linux/bin/dmd

and then possibly do the same for dumpobj obj2asm and rdmd, if you feel 
you'll use them often enough not to bother writing the whole path to 
them each time.

At next login you can compile anything using either

$ dmd1 myfile.d
$ dmd2 myfile.d

(which is essentially how I plan on having it.)

(And when this didn't work, one obviously had forgotten to do the chmod. 
:-) )

> I'd give instructions for both, probably putting the path instructions first.
> (You'd also want to do that on Windows, so it is the most cross platform and
> the least invasive method.)



More information about the Digitalmars-d mailing list