www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - undefined reference to `_init_12TypeInfo_AAh'

reply Yves Jacoby <kloune gmail.com> writes:
I'm trying to program some sorting algorithms in D (mainly to play
around). So I have a module called "sort" and a "main.d" which imports
"sort". I have a template Sorting, which has the different sorting
algorithms. 

Now, in the module, I wanted to print out an array, with

writefln("%s\n",elements);

where elements is "T[] elements" and T is the template parameter. Now,
when I compile everything:

 gdc -fbounds-check -c sort.d
 gdc -fbounds-check -o main sort.o main.d
/tmp/ccSBSZs8.o:(.data+0x20): undefined reference to `_init_12TypeInfo_AAh' collect2: ld returned 1 exit status I get this error. Can someone perhaps tell me where the problem is ? If I remove the "writefln(...)" everything links right again. Thank you.
Jan 28 2006
parent reply Carlos Santander <csantander619 gmail.com> writes:
Yves Jacoby escribió:
 I'm trying to program some sorting algorithms in D (mainly to play
 around). So I have a module called "sort" and a "main.d" which imports
 "sort". I have a template Sorting, which has the different sorting
 algorithms. 
 
 Now, in the module, I wanted to print out an array, with
 
 writefln("%s\n",elements);
 
 where elements is "T[] elements" and T is the template parameter. Now,
 when I compile everything:
 
 gdc -fbounds-check -c sort.d
 gdc -fbounds-check -o main sort.o main.d
/tmp/ccSBSZs8.o:(.data+0x20): undefined reference to `_init_12TypeInfo_AAh' collect2: ld returned 1 exit status I get this error. Can someone perhaps tell me where the problem is ? If I remove the "writefln(...)" everything links right again. Thank you.
Maybe you can post some code? -- Carlos Santander Bernal
Jan 29 2006
parent reply Yves Jacoby <kloune gmail.com> writes:
On Sun, 29 Jan 2006 16:00:53 -0500, Carlos Santander wrote:

 Yves Jacoby escribió:
 I'm trying to program some sorting algorithms in D (mainly to play
 around). So I have a module called "sort" and a "main.d" which imports
 "sort". I have a template Sorting, which has the different sorting
 algorithms. 
 
 Now, in the module, I wanted to print out an array, with
 
 writefln("%s\n",elements);
 
 where elements is "T[] elements" and T is the template parameter. Now,
 when I compile everything:
 
 gdc -fbounds-check -c sort.d
 gdc -fbounds-check -o main sort.o main.d
/tmp/ccSBSZs8.o:(.data+0x20): undefined reference to `_init_12TypeInfo_AAh' collect2: ld returned 1 exit status I get this error. Can someone perhaps tell me where the problem is ? If I remove the "writefln(...)" everything links right again. Thank you.
Maybe you can post some code?
Here is the code for sort.d: ------------------------ module sort; import std.stdio; import std.random; template Sorting(T) { void insertSort(T[] elements) in{ } out{ } body { writefln("%s\n",elements); } } ------------------------ and main.d ------------------------ import std.stdio; import std.random; import sort; static uint ELNUM = 4000; int main(){ ubyte[][] strings = new ubyte[][ELNUM]; for(int i = 0;i<ELNUM;i++){ strings[i] = new ubyte[rand()%200]; strings[i][] = (rand()%60)+'a'; } Sorting!(ubyte[]).insertSort(strings.dup); return 0; } ------------------------- I tried to reduce it to a minimum that still works.
Jan 30 2006
parent reply Carlos Santander <csantander619 gmail.com> writes:
Yves Jacoby escribió:
 
 Here is the code for sort.d:
 ------------------------
 module sort;
 
 import std.stdio;
 import std.random;
 
 template Sorting(T) {
 
         void insertSort(T[] elements)
         in{
         }
         out{
         }
         body {
                 writefln("%s\n",elements);
         }
 }
 ------------------------
 and main.d
 ------------------------
 import std.stdio;
 import std.random;
 import sort;
 
 static uint ELNUM = 4000;
 
 int main(){
 
         ubyte[][] strings = new ubyte[][ELNUM];
 
         for(int i = 0;i<ELNUM;i++){
                 strings[i] = new ubyte[rand()%200];
                 strings[i][] = (rand()%60)+'a';
         }
 
         Sorting!(ubyte[]).insertSort(strings.dup);
 
         return 0;
 }
 -------------------------
 I tried to reduce it to a minimum that still works.
 
 
Quick fix: add this line to sort.d: alias Sorting!(ubyte[]) Sorting_ubyte; The alias name can be anything. It's an ugly fix, but it works. -- Carlos Santander Bernal
Jan 30 2006
parent reply Yves Jacoby <kloune gmail.com> writes:
On Mon, 30 Jan 2006 19:20:54 -0500, Carlos Santander wrote:

 Yves Jacoby escribió:
 
 Here is the code for sort.d:
 ------------------------
 module sort;
 
 import std.stdio;
 import std.random;
 
 template Sorting(T) {
 
         void insertSort(T[] elements)
         in{
         }
         out{
         }
         body {
                 writefln("%s\n",elements);
         }
 }
 ------------------------
 and main.d
 ------------------------
 import std.stdio;
 import std.random;
 import sort;
 
 static uint ELNUM = 4000;
 
 int main(){
 
         ubyte[][] strings = new ubyte[][ELNUM];
 
         for(int i = 0;i<ELNUM;i++){
                 strings[i] = new ubyte[rand()%200];
                 strings[i][] = (rand()%60)+'a';
         }
 
         Sorting!(ubyte[]).insertSort(strings.dup);
 
         return 0;
 }
 -------------------------
 I tried to reduce it to a minimum that still works.
 
 
Quick fix: add this line to sort.d: alias Sorting!(ubyte[]) Sorting_ubyte; The alias name can be anything. It's an ugly fix, but it works.
Thanks. I fixed it by just writing a function that does it. Anyway, what I wanted to know was more bug in compiler or my error.
Jan 31 2006
parent Carlos Santander <csantander619 gmail.com> writes:
Yves Jacoby escribió:
 
 Thanks. I fixed it by just writing a function that does it. Anyway, what I
 wanted to know was more bug in compiler or my error.
I don't know about you but I tested it with GDC. Maybe someone who uses DMD can test it and see what happens (I have a gut feeling it's going to fail too), and if it's so, then a bug report can be posted to D.bugs. -- Carlos Santander Bernal
Jan 31 2006