如何在 Mac OS X 10.6 (Snow Leopard) 上开始使用 D

发布于 2024-08-23 23:19:36 字数 1160 浏览 3 评论 0 原文

我对“D”感兴趣已有几年了,最近决定开始实际使用它。我已经能够很容易地掌握基础知识,我喜欢该语言的基本功能集,并且我读得越多,印象就越深刻。

现在,我对编写一个自定义 Web 应用程序服务器作为业余爱好项目非常感兴趣,我希望它是一个简单的二进制文件,为实际的 Web 应用程序使用动态链接库。我相信 D 是这个项目的完美语言。

只有一个大问题......在过去的几天里,我完全无法让任何类型的 IDE 设置正常工作。我可以在命令行上编译和运行所有内容,但我在任何可用的 IDE 中尝试的所有内容(Code::Blocks、eclipse+descent、带有 D 插件的 Xcode,甚至在 Windows 上的 VirtualBox 中运行的 Windows D-IDE XP Pro)唯一发生的事情是:

object.d: Error: module object Cannot read file 'object.d'

经过两天的尝试不同的事情并遵循教程,这真的很糟糕我的神经。我想学习有效地使用 D,但如果我想保持理智,我需要一些舒适的工具链,其中包括编辑器中的代码完成功能,我显然是这样做的。

[编辑:强调了真正重要的一点]

有没有人可以帮助我设置 Eclipse 或(最好)netbeans(但没有插件)似乎是公开的)给我在 IDE 中编译和运行的能力,以及代码完成?在我的 Mac 上,运行 Mac OS X 10.6?

我想使用 phobos 库(因此需要 2.0 编译器),但我并不关心它是否 dmdgdmd (gdcmac)

[补充]

我相信我们可以假设我的 dmd 编译器安装是有序的,因为它可以从命令行运行。我只是不想从命令行使用它,因为它很乏味。问题是关于 IDE,编译器可以工作,只是 IDE 不能工作

I've been interested in "D" for a couple of years now and recently decided to start actually playing with it. I've been able to grasp the basics quite easily, I love the basic feature set of the language and the more I read about it, the more impressed I get.

Now, I'm very interested in writing a custom web application server as a hobby project and I want it to be a simple binary, using dynamically linked libraries for the actual web applications. I believe D to be the perfect language for this venture.

There is only one big problem... over the past couple of days, I have been completely unable to get any kind of IDE setup working. I can compile and run everything just fine on the command line, but everything I try in any of the IDE's available (Code::Blocks, eclipse+descent, Xcode with D plugin, and even the windows D-IDE running in VirtualBox on Windows XP Pro) the only thing that ever happens is:

object.d: Error: module object cannot read file 'object.d'

After two days of trying different things and following tutorials, this is really getting on my nerves. I want to learn to use D efficiently, but I need some comfy tool chain that includes code completion in the editor if I want to keep my sanity, which I obviously do.

[edit:added emphasis to the really important bit]

Is there anyone that can help me set up eclipse or (preferably) netbeans (but no plugin seems to be publicly available) to give me compile and run abilities in the IDE, along with code completion? on my Mac, running Mac OS X 10.6?

I want to use the phobos libraries (and therefor a 2.0 compiler) but I don't really care if its dmd or gdmd (gdcmac).

[addition]

I believe we can assume that my dmd compiler installation is in order because it works from the commandline. I just don't want to use it from the commandline because its tedious. The question is about and IDE, the compiler works, its just IDEs that won't

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

隱形的亼 2024-08-30 23:19:36

好吧,我内心的顽固分子无法让这个问题不管,我终于让它发挥作用了。

在 Mac OS X 10.6 上运行所需的组件有:

  • DMD 编译器
  • Eclipse“Galileo”(版本 3.4)
  • Descent
  • DSSS
  • /usr/etc/rebuild/default 的更改
  • 我破解的新文件一起 /usr/etc/rebuild/macosx.conf
  • Eclipse 的全局和每个项目设置

按照这些说明操作后,您将让 Eclipse 能够对您的 D 项目进行代码补全,并且您将能够也可以从 IDE 中构建/运行。

使其运行的实际步骤如下。

  1. 安装digitalmars dmd 2.0编译器
    1. digitalmars.com 下载二进制发行版 (直接链接到 2.041)
    2. 将下载的文件解压到 ~/somefolder(这为我创建了一个 ~/somefolder/dmd2 文件夹,我将在本示例中使用该文件夹。)
    3. 在终端 (/Applications/Utilities/Terminal.app) 中将文件移动到目的地
    4. sudo mv ~/somefolder/dmd2/osx/bin/* /usr/bin/ 在询问时输入您的登录密码
    5. 将刚刚复制的 dmd.conf 移动到其位置: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. 使用您最喜欢的文本编辑器编辑 /etc/dmd.conf 以包含以下内容:

[环境]

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

  1. 从数百个可用的 Eclipse 版本中下载并安装您最喜欢的 Mac OS X 版本在 http://www.eclipse.org/downloads/ (我选择了 c/ 的可可版本c++)
  2. 安装 Descent(几乎按照wiki 中的常规说明
    1. 运行 Eclipse(不必以 root 身份运行)
    2. 转到帮助 ->从菜单栏安装新软件。 (天哪,这在帮助菜单中起作用吗?!)
    3. http://downloads.dsource.org/projects/descent/update-site 复制/粘贴到网址字段中。
    4. 按照屏幕上的说明完成安装。
  3. 安装 来自 sourceforge 的 dss (直接链接到 .dmg)
    1. 像其他任何程序一样使用磁盘映像上的安装程序包。
    2. 创建一个文件 /usr/etc/rebuild/macosx.conf 并将以下代码片段粘贴到其中。 (并保存,废话)
profile=phobos
编译器=dmd
ini文件=dmd.conf
执行文件=
对象外部=o
版本=DigitalMars
noversion=GNU
版本=MacOSX
版本=linux
noversion=Unix
noversion=Posix
noversion=Windows
noversion=Win32
noversion=Win64
版本=X86
noversion=PPC
noversion=X86_64
版本=D_InlineAsm
版本=D_InlineAsm_X86
noversion=D_InlineAsm_PPC
noversion=D_InlineAsm_X86_64
版本=LittleEndian
noversion=BigEndian

[编译]
cmd=dmd -version=MacOSX -c $i
标志=$i
incdir=-I$i
libdir=-LL$i
优化=-O
版本=-版本=$i

[关联]
一次=是
#cmd=dmd -L-lphobos $i -of$o
cmd=dmd $i -of$o
# cmd=dmd -L--start-group -L-lphobos $i -of$o

libdir=-LL$i
lib=-Ll$i
标志=-L$i

[库链接]
安全=是
一次=是
cmd=如果 [ ! -z“$o”];然后 ar rc $o $i;菲

库目录=
库=
标志=

[后库链接]
cmd=ranlib $i

[shlib链接]
shlibs=否

[dylib链接]
dylibs=否
  1. /usr/etc/rebuild/default 文件更改为:profile=dmd-macosx
  2. 设置 Eclipse 以完成代码
  3. 在全局 Eclipse 首选项中导航 tp D => 构建路径 => 用户库
    1. 点击新建,输入“std”,按确定选择新创建的条目,点击添加目录
      • 导航到 /usr/dmd2/src/phobos/std 并添加它。
    2. 设置 Eclipse 项目。
      您必须为要制作的每个 D 项目手动执行此操作
    3. 使用“D => D Project”向导创建一个新项目(感谢 Descent)
    4. 进入项目属性(在项目资源管理器中右键单击项目并选择“属性”)
    5. 在左侧列表中选择 D 构建路径,然后在出现的面板中选择包含路径 选项卡。
    6. 点击添加库按钮并在向导的第二页中选择std
    7. 配置外部构建工具
    8. 转到外部工具配置...(从绿色小播放按钮的下拉菜单中,在构建/运行/调试工具栏前面有工具箱)
    9. 在左侧列表中右键单击程序,然后从上下文菜单中选择新建
    10. 为您的配置指定一个合适的名称,例如“Build with dsss”,并设置以下选项:
      • 位置:/usr/bin/dsss
      • 工作目录:包含项目 dsss.conf 文件的目录的完整路径
        (如果您没有 dsss.conf 文件,请在命令行上创建一个:dsss genconfig
      • 参数:构建(或重建,或清理,或...)
    11. 针对您需要的任意数量的构建/运行选项,重复上述步骤 2 和 3。

恭喜,现在一切都应该正常了。

如果由于某种原因这对您不起作用,请告诉我,我将很乐意找出问题所在并帮助您使其正常工作。如果有更好或更简单的方法,我也很想知道。

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.

飘然心甜 2024-08-30 23:19:36
object.d: Error: module object cannot read file 'object.d'

清楚地表明它无法正确找到库。所以,第一个问题是你的 dmd.conf 是如何设置的。您需要确保它指向 src/phobos、src/druntime/import 和 osx/lib 的正确位置 - 无论您将它们放在哪里。就我个人而言,我将 dmd 代码放在 home 的子文件夹中,并且不尝试将其安装在 /usr 中,但说明确实告诉您将它们作为默认安装在那里,所以它应该可以工作。

假设您的 dmd.conf 看起来没问题,最有可能的情况是它实际上使用了错误的 dmd.conf。按照数字火星网站上的说明 (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/

我的猜测是您将 dmd.conf 放在 /etc 中并一直在编辑该文件,但将原始 dmd.conf 留在了当然

/where_dmd_is/dmd2/osx/bin/

,我已经发生过这种情况对我来说有一两次。无论如何,您需要确保的第一件事是您正在编辑的 dmd.conf 是 dmd 正在使用的(因此请确保 dmd 首先查找的地方没有 dmd.conf)。 conf),您需要确保的第二件事是 dmd.conf 中的路径正确指向 dmd 内容所在的位置。如果这两件事是正确的,那么 dmd 应该正确找到库。

顺便说一句,但是,鉴于您关于想要使用共享库的评论,共享库现在无法与 D2 一起正常工作(我不知道它们是否可以与 D1 一起工作,因为我不使用D1 - 我怀疑他们没有)。 D 新闻组 ( http://www.digitalmars.com/NewsGroup.html ),这样你就可以在那里查看。它已经受到关注并正在研究中,但尚未完全发挥作用。此外,您还可以查看新闻组以获取有关 D 相关问题的进一步帮助。这可能是现在最好的提问地点。

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.

无敌元气妹 2024-08-30 23:19:36

如果是IDE的问题,就eclipse而言,我相信要查看的插件是下降的: http://www.dsource.org/projects/descent

不幸的是,我自己还没有尝试过,所以我不知道它有多好。根据其 wiki 页面,它主要用于 D1,但至少在某种程度上支持 D2。

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.

萌无敌 2024-08-30 23:19:36

如果您想快速开始(又名双击安装):D for Xcode

要求:

  • Xcode

就是这样。安装最新的 dmd 编译器,因此它也可以在终端等中运行。

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.

月竹挽风 2024-08-30 23:19:36

当我时不时地看到这个问题出现在我的搜索结果中时,我想我应该保持它的相关性。

如今;在 Mountain Lion 时代,Mono-D 项目中存在一个更简单的解决

方案安装 MonoDevelop(或 Xamarin Studio)并按照五分钟安装手册进行操作

As i keep seeing this question coming back in my search results every now and then, I figured I'd keep it relevant.

Nowadays; In the Mountain Lion era, a much easier solution exists in the Mono-D project

Just install MonoDevelop (or Xamarin Studio) and follow the five minute installation manual

在你怀里撒娇 2024-08-30 23:19:36

(你可以在 D 1.0 上使用 Phobos。无论如何......)

你在哪里安装了 Phobos 和 druntime 头文件?

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

通常我将它们复制/usr/include中。

(另外,尝试编辑dmd.conf以使用绝对路径

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

:)

(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

)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文