我对“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 编译器),但我并不关心它是否 dmd 或 gdmd (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
发布评论
评论(6)
好吧,我内心的顽固分子无法让这个问题不管,我终于让它发挥作用了。
在 Mac OS X 10.6 上运行所需的组件有:
/usr/etc/rebuild/default
的更改/usr/etc/rebuild/macosx.conf
按照这些说明操作后,您将让 Eclipse 能够对您的 D 项目进行代码补全,并且您将能够也可以从 IDE 中构建/运行。
使其运行的实际步骤如下。
~/somefolder
(这为我创建了一个 ~/somefolder/dmd2 文件夹,我将在本示例中使用该文件夹。)/Applications/Utilities/Terminal.app
) 中将文件移动到目的地sudo mv ~/somefolder/dmd2/osx/bin/* /usr/bin/
在询问时输入您的登录密码sudo mv /usr/bin/dmd.conf /etc/dmd.conf
sudo mv ~/somefolder/dmd2/osx/lib/* /usr/lib/
sudo mv ~/somefolder/dmd2 /usr/
/etc/dmd.conf
以包含以下内容:帮助
->从菜单栏安装新软件
。 (天哪,这在帮助
菜单中起作用吗?!)http://downloads.dsource.org/projects/descent/update-site
复制/粘贴到网址字段中。/usr/etc/rebuild/macosx.conf
并将以下代码片段粘贴到其中。 (并保存,废话)/usr/etc/rebuild/default
文件更改为:profile=dmd-macosx
D
=>构建路径
=>用户库
新建
,输入“std”,按确定
选择新创建的条目,点击添加目录
/usr/dmd2/src/phobos/std
并添加它。您必须为要制作的每个 D 项目手动执行此操作
D 构建路径
,然后在出现的面板中选择包含路径
选项卡。添加库
按钮并在向导的第二页中选择std
。外部工具配置...
(从绿色小播放按钮的下拉菜单中,在构建/运行/调试工具栏前面有工具箱)程序
,然后从上下文菜单中选择新建
。/usr/bin/dsss
(如果您没有 dsss.conf 文件,请在命令行上创建一个:
dsss genconfig
)构建
(或重建,或清理,或...)恭喜,现在一切都应该正常了。
如果由于某种原因这对您不起作用,请告诉我,我将很乐意找出问题所在并帮助您使其正常工作。如果有更好或更简单的方法,我也很想知道。
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:
/usr/etc/rebuild/default
/usr/etc/rebuild/macosx.conf
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.
~/somefolder
(that created a ~/somefolder/dmd2 folder for me which I'll use for the duration of this example.)/Applications/Utilities/Terminal.app
) move the files to their destinationsudo mv ~/somefolder/dmd2/osx/bin/* /usr/bin/
enter your login password when askedsudo mv /usr/bin/dmd.conf /etc/dmd.conf
sudo mv ~/somefolder/dmd2/osx/lib/* /usr/lib/
sudo mv ~/somefolder/dmd2 /usr/
/etc/dmd.conf
to contain the following:Help
->Install New Software
from the menu bar. (wtf does that do in theHelp
menu?!)http://downloads.dsource.org/projects/descent/update-site
into the url field./usr/etc/rebuild/macosx.conf
and paste the following snippet into it. (and save, duh)/usr/etc/rebuild/default
file to read:profile=dmd-macosx
D
=>Build Path
=>User Libraries
New
, type "std", pressOK
select the newly created entry, clickAdd Directory
/usr/dmd2/src/phobos/std
and add it.You have to do this manually for every D project you'll make
D Build Path
and in the panel that appears choose theInclude Path
tab.Add Library
button and choosestd
in the second page of the wizard.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)Program
and chooseNew
from the context menu./usr/bin/dsss
(if you don't have a dsss.conf file create one on the commandline:
dsss genconfig
)build
(or rebuild, or clean, or...)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.
清楚地表明它无法正确找到库。所以,第一个问题是你的 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.conf 放在 /etc 中并一直在编辑该文件,但将原始 dmd.conf 留在了当然
,我已经发生过这种情况对我来说有一两次。无论如何,您需要确保的第一件事是您正在编辑的 dmd.conf 是 dmd 正在使用的(因此请确保 dmd 首先查找的地方没有 dmd.conf)。 conf),您需要确保的第二件事是 dmd.conf 中的路径正确指向 dmd 内容所在的位置。如果这两件事是正确的,那么 dmd 应该正确找到库。
顺便说一句,但是,鉴于您关于想要使用共享库的评论,共享库现在无法与 D2 一起正常工作(我不知道它们是否可以与 D1 一起工作,因为我不使用D1 - 我怀疑他们没有)。 D 新闻组 ( http://www.digitalmars.com/NewsGroup.html ),这样你就可以在那里查看。它已经受到关注并正在研究中,但尚未完全发挥作用。此外,您还可以查看新闻组以获取有关 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 ):
My guess is that you put dmd.conf in /etc and have been editing that one but left the original dmd.conf in
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.
如果是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.
如果您想快速开始(又名双击安装):D for Xcode
要求:
就是这样。安装最新的 dmd 编译器,因此它也可以在终端等中运行。
If you wanna get started quickly (aka Double-click-install): D for Xcode
Requirements:
That's it. Installs the latest dmd compiler, so it works in Terminal too etc.
当我时不时地看到这个问题出现在我的搜索结果中时,我想我应该保持它的相关性。
如今;在 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
(你可以在 D 1.0 上使用 Phobos。无论如何......)
你在哪里安装了 Phobos 和 druntime 头文件?
通常我将它们复制到
/usr/include
中。(另外,尝试编辑
dmd.conf
以使用绝对路径:)
(You can use Phobos on D 1.0. Anyway…)
Where did you install the Phobos and druntime headers?
Usually I copy them into
/usr/include
.(Also, try to edit
dmd.conf
to use the absolute path:)