View previous topic :: View next topic |
Author |
Message |
wing
Joined: 08 Mar 2005 Posts: 1
|
Posted: Tue Mar 08, 2005 7:29 pm Post subject: new to D, why won't this compile? (Symbol Undefined) |
|
|
Edit: great, within minutes of me posting this I figure out that main just doesn't like to be in a class. meh.
I've been toying around lately with D, and I really like it so far. I decided to port a small app that I wrote in an old Java class, and for the life of me I can't figure out what's wrong. It will probably be something really obvious though, be my eyes!
Here is the source for DArray.d
Code: | import std.stdio;
import std.random;
class DArray
{
public:
void main(char[][] args)
{
List arraylist = new List(10);
arraylist.print();
arraylist.fillWithRandom();
arraylist.print();
}
}
class List
{
private:
int[] intarray;
int total = 0;
public:
this(int numInts)
{
intarray.length = numInts;
for(int i = 0; i < intarray.length; i++)
intarray[i] = 0;
}
void fillWithRandom()
{
for(int i = 0; i < intarray.length; i++)
intarray[i] = rand() ? 50;
}
void print()
{
for(int i = 0; i < intarray.length; i++)
writef(intarray[i]);
writef("----");
}
}
|
Here's what the compiler spits out:
Code: | dmd array.d
C:\dmd\bin\..\..\dm\bin\link.exe array,,,user32+kernel32/noi;
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
OPTLINK : Warning 23: No Stack
array.obj(array)
Error 42: Symbol Undefined _D9invariant12_d_invariantFC6ObjectZv
array.obj(array)
Error 42: Symbol Undefined __d_newclass
array.obj(array)
Error 42: Symbol Undefined __d_arraysetlength
array.obj(array)
Error 42: Symbol Undefined __d_array_bounds
array.obj(array)
Error 42: Symbol Undefined _D3std6random4randFZk
array.obj(array)
Error 42: Symbol Undefined _D3std5stdio6writefFYv
array.obj(array)
Error 42: Symbol Undefined __init_11TypeInfo_Aa
array.obj(array)
Error 42: Symbol Undefined __init_10TypeInfo_i
array.obj(array)
Error 42: Symbol Undefined _D6object6Object8opEqualsFC6ObjectZi
array.obj(array)
Error 42: Symbol Undefined _D6object6Object5opCmpFC6ObjectZi
array.obj(array)
Error 42: Symbol Undefined _D6object6Object6toHashFZk
array.obj(array)
Error 42: Symbol Undefined _D6object6Object8toStringFZAa
array.obj(array)
Error 42: Symbol Undefined __Class_6Object
array.obj(array)
Error 42: Symbol Undefined __vtbl_9ClassInfo
array.obj(array)
Error 42: Symbol Undefined _D6object6Object5printFZv
array.obj(array)
Error 42: Symbol Undefined __nullext
array.obj(array)
Error 42: Symbol Undefined __ModuleInfo_3std5stdio
array.obj(array)
Error 42: Symbol Undefined __ModuleInfo_3std6random
OPTLINK : Warning 134: No Start Address
--- errorlevel 18
|
Hope you guys can help me out, thanks in advance! |
|
Back to top |
|
|
Derek Parnell
Joined: 22 Apr 2004 Posts: 408 Location: Melbourne, Australia
|
Posted: Wed Mar 09, 2005 3:10 am Post subject: |
|
|
I assume you used
to compile this.
That is okay, except that dmd normally calls the linker after the compiler has run, and what you are seeing is a whole lot of messages from the linker.
The problem is that it is expecting that a main() will be present somewhere. So, either add the lines ..
or compile with the "-c" switch. That will do a compile-only run - no linker. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|