A: 

(You can use Phobos on D 1.0. Anyway…)

Where did you install the Phobos and druntime headers?

<the .zip file>/src/druntime/
<the .zip file>/src/phobos/

Usually I copy them into /usr/include.

(Also, try to edit dmd.conf to use the absolute path:

[Environment]
DFLAGS=-I/usr/include/phobos -I/usr/include/druntime/import -L-L/usr/lib

)

KennyTM
I already edited the dmd.conf to have absolute paths (DFLAGS=-I/usr/dmd2/src/phobos -I/usr/dmd2/src/druntime/import -L-L/usr/dmd2/lib) I also symlinked the binaries into /usr/bin _and_ added all dmd2 related paths to my PATH environment (bash profile), unfortunately makes no difference.
Kris
A: 
object.d: Error: module object cannot read file 'object.d'

clearly indicates that it can't find the libraries properly. So, the first question is how your dmd.conf is set up. You need to make sure that it's pointing to the correct places for src/phobos, src/druntime/import, and osx/lib - wherever you put those. Personally, I put the dmd code in a subfolder of home and don't try and install it in /usr, but the instructions do tell you to install them there as the default, so it should work.

Assuming that your dmd.conf looks okay, the most likely situation is that it's actually using the wrong dmd.conf. Per the instructions on the digital mars site ( http://www.digitalmars.com/d/2.0/dmd-osx.html ):

dmd will look for the initialization file dmd.conf in the following sequence of directories:

 1. current working directory
 2. directory specified by the HOME environment
 3. variable directory dmd resides in
 4. /etc/

My guess is that you put dmd.conf in /etc and have been editing that one but left the original dmd.conf in

/where_dmd_is/dmd2/osx/bin/

Certainly, I've had that happen to me a time or two. In any case, the first thing that you need to make sure of is that the dmd.conf that you're editing is the one that dmd is using (so make sure that the places where dmd looks first don't have a dmd.conf), and the second thing that you need to make sure of is that the paths in your dmd.conf correctly point to where the dmd stuff is. If those two things are correct, then dmd should find the libraries correctly.

On a side note, I would point out, however, given your comment about wanting to use shared libraries is that shared libraries don't work correctly with D2 right now (I have no idea whether they work with D1 since I don't use D1 - I suspect that they don't though). There have been discussions about it on the D newsgroup ( http://www.digitalmars.com/NewsGroup.html ), so you can look there. It is something on the radar and is being looked into, but doesn't fully work yet. Also, you can look to the newsgroup for further help on D-related issues. It's probably the best place to ask right now.

Jonathan M Davis
the libraries may be static instead of dynamic so that's not a problem and if it becomes a problem I could most likely fix it if given a decently working environment anyway. I didn't keep the original files since I could easily unpack them again, there is only one dmd.conf on my system and it's in /etc/ `sudo find / -name "dmd.conf" -print` told me that. And I have again assured myself that all paths are setup correctly.
Kris
A: 

If it's a question of an IDE, as far as eclipse goes, I believe that the plugin to look at is descent: http://www.dsource.org/projects/descent

Unfortunately, I haven't tried it myself yet, so I don't know how good it is. According to its wiki page, it's primarily intended for D1 but does support D2 to at least some extent.

Jonathan M Davis
I have installed eclipse and descent, along with dsss. code completion doesn't work for anything in the std library (phobos) and compilation won't work at all even though the compile time view and type browsers do work. I have looked at the wikis and all but there is no walkthrough that ends up in me having a working IDE, that's why I asked here
Kris
+8  A: 

Well, the persistent bugger in me could not leave the problem alone and I finally got it to work.

The required components to get it all working on Mac OS X 10.6 are:

  • DMD compiler
  • Eclipse "Galileo" (version 3.4)
  • Descent
  • DSSS
  • a change to /usr/etc/rebuild/default
  • a new file i hacked together /usr/etc/rebuild/macosx.conf
  • global and per-project settings for Eclipse

After following these instructions you'll have Eclipse able to do code completion on your D projects and you'll be able to build/run from within the IDE as well.

The actual steps to get it operational are as follows.

  1. install the digitalmars dmd 2.0 compiler
    1. download the binary distribution from digitalmars.com (direct link to 2.041)
    2. unzip the downloaded file into ~/somefolder (that created a ~/somefolder/dmd2 folder for me which I'll use for the duration of this example.)
    3. in the terminal (/Applications/Utilities/Terminal.app) move the files to their destination
    4. sudo mv ~/somefolder/dmd2/osx/bin/* /usr/bin/ enter your login password when asked
    5. move the just copied dmd.conf to its location: sudo mv /usr/bin/dmd.conf /etc/dmd.conf
    6. sudo mv ~/somefolder/dmd2/osx/lib/* /usr/lib/
    7. sudo mv ~/somefolder/dmd2 /usr/
    8. use your favorite text editor to edit /etc/dmd.conf to contain the following:

[Environment]

DFLAGS=-I/usr/dmd2/src/phobos -I/usr/dmd2/src/druntime/import -L-L/usr/lib

  1. Download and install your favorite Mac OS X version of eclipse out of the umpteen hundreds available at http://www.eclipse.org/downloads/ (I picked a cocoa version for c/c++)
  2. Install Descent (almost as per the normal instructions in the wiki)
    1. run Eclipse (don't bother running as root)
    2. goto Help -> Install New Software from the menu bar. (wtf does that do in the Help menu?!)
    3. copy/paste http://downloads.dsource.org/projects/descent/update-site into the url field.
    4. follow on screen instructions to finish installation.
  3. install dsss from sourceforge (direct link to .dmg)
    1. use the installer package on the disk image like any other.
    2. create a file /usr/etc/rebuild/macosx.conf and paste the following snippet into it. (and save, duh)
profile=phobos
compiler=dmd
inifile=dmd.conf
exeext=
objext=o
version=DigitalMars
noversion=GNU
version=MacOSX
version=linux
noversion=Unix
noversion=Posix
noversion=Windows
noversion=Win32
noversion=Win64
version=X86
noversion=PPC
noversion=X86_64
version=D_InlineAsm
version=D_InlineAsm_X86
noversion=D_InlineAsm_PPC
noversion=D_InlineAsm_X86_64
version=LittleEndian
noversion=BigEndian

[compile]
cmd=dmd -version=MacOSX -c $i
flag=$i
incdir=-I$i
libdir=-L-L$i
optimize=-O
version=-version=$i

[link]
oneatatime=yes
#cmd=dmd -L-lphobos $i -of$o
cmd=dmd $i -of$o
# cmd=dmd -L--start-group -L-lphobos $i -of$o

libdir=-L-L$i
lib=-L-l$i
flag=-L$i

[liblink]
safe=yes
oneatatime=yes
cmd=if [ ! -z "$o" ]; then ar rc $o $i; fi

libdir=
lib=
flag=

[postliblink]
cmd=ranlib $i

[shliblink]
shlibs=no

[dyliblink]
dylibs=no
  1. change the /usr/etc/rebuild/default file to read: profile=dmd-macosx
    1. Set up Eclipse to have code completion
  2. In the global eclipse preferences navigate tp D => Build Path => User Libraries
    1. click New, type "std", press OK select the newly created entry, click Add Directory
      • navigate to /usr/dmd2/src/phobos/std and add it.
    2. Set up Eclipse project. You have to do this manually for every D project you'll make
    3. Create a new project with the "D => D Project" wizard (thanks to Descent)
    4. Go into project properties (right click project in the Project Explorer and choose Properties)
    5. In the list to the left select D Build Path and in the panel that appears choose the Include Path tab.
    6. Click the Add Library button and choose std in the second page of the wizard.
    7. Configure the extarnal build tool
    8. Go to External tools configurations... (from the dropdown in the little green play button with the toolbox in front of it in the build/run/debug toolbar thingy)
    9. In the list to the left right click Program and choose New from the context menu.
    10. give your config a decent name like "Build with dsss" and set the following options:
      • Location: /usr/bin/dsss
      • Working Directory: full path to directory with your dsss.conf file for the project (if you don't have a dsss.conf file create one on the commandline: dsss genconfig)
      • Arguments: build (or rebuild, or clean, or...)
    11. repeat steps 2 and 3 above for as many build/run options as you require.

Congratulations, everything should work now.

If for some reason this does not work for you, let me know and I'll be happy to figure out where it went wrong and help you to get it working. If there's a better or simpler way, I'd love to know about it as well.

Kris
Somewhat sad that I didn't get a better answer than this mess here.
Kris
+1  A: 

If you wanna get started quickly (aka Double-click-install): D for Xcode

Requirements:

  • Xcode

That's it. Installs the latest dmd compiler, so it works in Terminal too etc.

0scar
trying that now, the version(s) of D for Xcode found back when I asked this question didn't work, here's hoping it's better now.
Kris
mostly the same issues I had before, code completion doesn't really work (just keywords from current file), no debugging support (breakpoints don't work) etc. etc.
Kris
Ah, sorry, I got ahead of myself. Yes, proper debugging and full code completion support is missing. This is mentioned in "known issues". I have a feeling that this is the "edge" of the current development. D is in alpha, after all. Maybe you can contribute these features yourself? *nudge nudge* : )
0scar