digitalmars.D.learn - Modules/Libraries
- Joseph Colton (28/28) Jan 02 2007 I would like to create a module for creating ODF documents using D. I h...
- Chris Nicholson-Sauls (8/42) Jan 02 2007 The code itself looks fine. What's your compile command line? Are you ...
- Joseph Colton (3/45) Jan 02 2007 Thank you. That solved the problem.
- Frits van Bommel (10/13) Jan 03 2007 There's also the alternative option if you want to compile each .d file
I would like to create a module for creating ODF documents using D. I have done this before in Perl and Python, but I was able to easily figure out how to create modules there. I currently have two files that I am trying to get to interface correctly. Here is the first file called ooolib.d: module ooolib; class Calc { public: this() { } char[] echo(char[] name) { return name; } } The second file is called test.d: import std.stdio; import ooolib; void main(char[][] args) { Calc doc = new Calc(); writefln(doc.echo("Hello World")); } For some reason I cannot seem to get them to work together. I get a lot errors that claim there are undefined references. I am obviously missing something, does anyone know what I am missing?
Jan 02 2007
Joseph Colton wrote:I would like to create a module for creating ODF documents using D. I have done this before in Perl and Python, but I was able to easily figure out how to create modules there. I currently have two files that I am trying to get to interface correctly. Here is the first file called ooolib.d: module ooolib; class Calc { public: this() { } char[] echo(char[] name) { return name; } } The second file is called test.d: import std.stdio; import ooolib; void main(char[][] args) { Calc doc = new Calc(); writefln(doc.echo("Hello World")); } For some reason I cannot seem to get them to work together. I get a lot errors that claim there are undefined references. I am obviously missing something, does anyone know what I am missing?The code itself looks fine. What's your compile command line? Are you including both modules in arguments to the compiler? Something like: dmd test.d ooolib.d (Not attacking your intelligence. Its just a common first mistake.) There's also the Build utility if you worry about command lines getting long. http://dsource.org/projects/build -- Chris Nicholson-Sauls
Jan 02 2007
== Quote from Chris Nicholson-Sauls (ibisbasenji gmail.com)'s articleJoseph Colton wrote:including bothI would like to create a module for creating ODF documents using D. I have done this before in Perl and Python, but I was able to easily figure out how to create modules there. I currently have two files that I am trying to get to interface correctly. Here is the first file called ooolib.d: module ooolib; class Calc { public: this() { } char[] echo(char[] name) { return name; } } The second file is called test.d: import std.stdio; import ooolib; void main(char[][] args) { Calc doc = new Calc(); writefln(doc.echo("Hello World")); } For some reason I cannot seem to get them to work together. I get a lot errors that claim there are undefined references. I am obviously missing something, does anyone know what I am missing?The code itself looks fine. What's your compile command line? Are youmodules in arguments to the compiler? Something like: dmd test.d ooolib.d (Not attacking your intelligence. Its just a common first mistake.) There's also the Build utility if you worry about command lines getting long. http://dsource.org/projects/build -- Chris Nicholson-SaulsThank you. That solved the problem.
Jan 02 2007
Chris Nicholson-Sauls wrote:The code itself looks fine. What's your compile command line? Are you including both modules in arguments to the compiler? Something like: dmd test.d ooolib.dThere's also the alternative option if you want to compile each .d file separately: pass -c to just compile without linking. Later, pass all the generated .o or .obj files (on Linux and Windows, respectively) to dmd to link them. But as Chris mentioned build comes highly recommended by many people. Not by me personally though, since I don't have much first-hand experience with it. Code::Blocks[1] is what I use and also works quite well. (don't get rc2, it's ancient) [1]: to get it, go to http://www.codeblocks.org and get a recent nightly
Jan 03 2007