View previous topic :: View next topic |
Author |
Message |
ViolentAJ
Joined: 05 Feb 2009 Posts: 56
|
Posted: Thu Feb 26, 2009 2:17 am Post subject: Problem Compiling Classes. |
|
|
Hello.
I am using D 1.0 and I am able to make simple programs. I want to start getting into the object oriented features and classes. However,w hwnever I try to compile modules as classes, I get the following error:
Code: |
Main.d => Main
OPTLINK (R) for Win32 Release 8.00.1
Copyright (C) Digital Mars 1989-2004 All rights reserved.
OPTLINK : Warning 23: No Stack
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined _D9invariant12_d_invariantFC6ObjectZv
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined __d_newclass
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined _D3std5stdio8writeflnFYv
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined _D14TypeInfo_Tuple6__vtblZ
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined _D11TypeInfo_Aa6__initZ
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined _D6object6Object8opEqualsMFC6ObjectZi
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined _D6object6Object5opCmpMFC6ObjectZi
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined _D6object6Object6toHashMFZk
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined _D6object6Object8toStringMFZAa
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined _D6object6Object5printMFZv
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined _D6Object7__ClassZ
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined _D9ClassInfo6__vtblZ
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined __nullext
dsss_objs\D\_Main.obj(_Main)
Error 42: Symbol Undefined _D3std5stdio12__ModuleInfoZ
OPTLINK : Warning 134: No Start Address
--- errorlevel 14
Error: Command failCommand C:\DProgramming\dsss-0.78-x86-windows\bin\rebuild.exe returned with code -1, aborting.
ed, aborting.
|
I don't know WTH is going on at all. Has anyone else encountered this problem?
If there's any other info that you need, please let me know and I'll try my best to fill you in (sry, I'm a n00b). |
|
Back to top |
|
|
csauls
Joined: 27 Mar 2004 Posts: 278
|
Posted: Thu Feb 26, 2009 10:01 pm Post subject: |
|
|
I really have no idea.
It would possibly help, though, to show your test program's code and the contents of dsss.conf, for completeness.
Actually, I do see one hint. The OPTLINK warning "No Start Address" usually means there's no main() function defined in any of the loaded modules. (Or at least, I have gotten it before, and that was the problem.) _________________ Chris Nicholson-Sauls |
|
Back to top |
|
|
ViolentAJ
Joined: 05 Feb 2009 Posts: 56
|
Posted: Fri Feb 27, 2009 2:53 am Post subject: |
|
|
The code for my class:
Code: |
module MeinClass;
public class MeinClass {
//Instance Variables
private:
int number;
//Default Constructor (notice that we use "this" instead of the class name, which gives us an error)
public:
this() {
this.number = 0;
}
//Overloaded Constructor
this(int num) {
this.number = num;
}
//Accessor Method
int getNumber() {
return this.number;
}
//Mutator Method
void setNumber(int newNum) {
this.number = newNum;
}
}
|
The code for the main class:
Code: |
module Main;
import std.stdio;
import MeinClass; //The other class must be imported.
public class Main {
void main(string[] args) {
//Instantiate a new MeinClass object using the default constructor
MeinClass foo = new MeinClass();
//And one with the overloaded
MeinClass bar = new MeinClass(7);
//Print out the numbers for both.
writefln("The value of foo.number = ");
writefln();
}
}
|
My dsss.conf simply contains one line:
|
|
Back to top |
|
|
csauls
Joined: 27 Mar 2004 Posts: 278
|
Posted: Fri Feb 27, 2009 8:28 am Post subject: |
|
|
Okay, now it all makes sense.
Just drop the MainClass, moving main() into the module itselfand all shall be shiny and good. In D the main() function is always procedural, as in C. _________________ Chris Nicholson-Sauls |
|
Back to top |
|
|
ViolentAJ
Joined: 05 Feb 2009 Posts: 56
|
Posted: Fri Feb 27, 2009 7:02 pm Post subject: |
|
|
Sweet. At least I can work in classes for now lol. Thanks for pointing that out . |
|
Back to top |
|
|
|