www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Linker bug with "static const TypeInfo" member

reply Victor Nakoryakov <Victor_member pathlink.com> writes:
Hi all.

Until last week I used DIDE for developing my project. Because project growth
recompiling it each time became annoying, so I decide to use PN2 as editor and
SCons system as builder. I wrote SConscripts, etc, etc, and try to compile. All
fine, all compiles but I've got some errors on link step. Something ala

src\rame\graphics\rsgl.obj(rsgl) 
Error 42: Symbol Undefined
__init_52TypeInfo_C4rame8graphics12rendertarget12ColorBuffer

I could not understand the reason for several days: all modules present, all
classes are implemented, etc. Today I spoted a problem and made exaple project
that models this situation:

 classes.d












class A { int a; }
 templ.d












class TemplateClass(T) { static const TypeInfo ti = typeid(T); }
 core.d












private import templ; private import classes; int main(char[][] args) { TemplateClass!(A) tc = new TemplateClass!(A)(); return 0; }
 SConstruct













Build output is: D:\dtest>scons scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... C:/dmd/bin/dmd -I. -IC:\dmd\src\phobos -c -ofclasses.obj classes.d C:/dmd/bin/dmd -I. -IC:\dmd\src\phobos -c -ofcore.obj core.d C:/dmd/bin/dmd -I. -IC:\dmd\src\phobos -c -oftempl.obj templ.d C:/dmd/bin/dmd -oftest.exe core.obj templ.obj classes.obj C:\dmd\bin\..\..\dm\bin\link.exe core+templ+classes,test.exe,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved core.obj(core) Error 42: Symbol Undefined __init_20TypeInfo_C7classes1A --- errorlevel 1 scons: *** [test.exe] Error 1 scons: building terminated because of errors. As you can see linker reports every class that will be transmited to TemplateClass as template parameter as undefined symbol. static const TypeInfo ti = typeid(T); line invokes this strange behaviour. I think this is a bug. But maybe I didn't understand something?
Jan 20 2005
next sibling parent Chris Newton <redshodan dot.gmail.dot.dooot.com> writes:
On Thu, 20 Jan 2005 12:42:09 +0000, Victor Nakoryakov wrote:

 Hi all.
 
 Until last week I used DIDE for developing my project. Because project growth
 recompiling it each time became annoying, so I decide to use PN2 as editor and
 SCons system as builder. I wrote SConscripts, etc, etc, and try to compile. All
 fine, all compiles but I've got some errors on link step. Something ala
 
 src\rame\graphics\rsgl.obj(rsgl) 
 Error 42: Symbol Undefined
 __init_52TypeInfo_C4rame8graphics12rendertarget12ColorBuffer
 
 I could not understand the reason for several days: all modules present, all
 classes are implemented, etc. Today I spoted a problem and made exaple project
 that models this situation:
 
 classes.d












class A { int a; }
 templ.d












class TemplateClass(T) { static const TypeInfo ti = typeid(T); }
 core.d












private import templ; private import classes; int main(char[][] args) { TemplateClass!(A) tc = new TemplateClass!(A)(); return 0; }
 SConstruct













Build output is: D:\dtest>scons scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... C:/dmd/bin/dmd -I. -IC:\dmd\src\phobos -c -ofclasses.obj classes.d C:/dmd/bin/dmd -I. -IC:\dmd\src\phobos -c -ofcore.obj core.d C:/dmd/bin/dmd -I. -IC:\dmd\src\phobos -c -oftempl.obj templ.d C:/dmd/bin/dmd -oftest.exe core.obj templ.obj classes.obj C:\dmd\bin\..\..\dm\bin\link.exe core+templ+classes,test.exe,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved core.obj(core) Error 42: Symbol Undefined __init_20TypeInfo_C7classes1A --- errorlevel 1 scons: *** [test.exe] Error 1 scons: building terminated because of errors. As you can see linker reports every class that will be transmited to TemplateClass as template parameter as undefined symbol. static const TypeInfo ti = typeid(T); line invokes this strange behaviour. I think this is a bug. But maybe I didn't understand something?

I have had what looks to be the same problem with the mintl library. It only happens for me when I templatize a mintl SortedAA on a function delegate. For example, this code fails to link: module test; import mintl.sortedaa; SortedAA!(char[],void delegate()) foo1; int main() { return 0; } Compiler output: [baron athe bug1]$ dmd test1.d -I../../include/phobos/ -I../../include ../../lib/libmintl.a gcc test1.o -o test1 ../../lib/libmintl.a -lphobos -lpthread -lm /usr/bin/ld: Warning: size of symbol `_D3std6stdarg9va_arg_Aa6va_argFKPvZAa' changed from 23 in test1.o to 34 in /usr/local/lib/libphobos.a(format.o) test1.o(.gnu.linkonce.t_D5mintl8sortedaa15SortedAA_AaDFZv8SortedAA8opEqualsFS5mintl8sortedaa15SortedAA_AaDF v8SortedAAZi+0x85): In function `_D5mintl8sortedaa15SortedAA_AaDFZv8SortedAA8opEqualsFS5mintl8sortedaa15SortedAA_AaDFZv8SortedAAZi': : undefined reference to `_init_13TypeInfo_DFZv' collect2: ld returned 1 exit status This is in linux, and it also fails to find an init TypeInfo instance. But if you insert a line like this in the single source file it will link. TypeInfo info=typeid(void delegate()); I'm glad you were able to track it down with more detail than I was. This has kept me from using mintl for now. :( Walter, any ideas on this one? Thanks! Chris Newton
Jan 19 2005
prev sibling next sibling parent nail <nail_member pathlink.com> writes:
- Doctor, doctor, everybody ignores me.
- The next, please. :)

Nobody collide with this problem? Maybe the sequence of dmd commands is wrong?

In article <cso8v1$2jnh$1 digitaldaemon.com>, Victor Nakoryakov says...
Hi all.

Until last week I used DIDE for developing my project. Because project growth
recompiling it each time became annoying, so I decide to use PN2 as editor and
SCons system as builder. I wrote SConscripts, etc, etc, and try to compile. All
fine, all compiles but I've got some errors on link step. Something ala

src\rame\graphics\rsgl.obj(rsgl) 
Error 42: Symbol Undefined
__init_52TypeInfo_C4rame8graphics12rendertarget12ColorBuffer

I could not understand the reason for several days: all modules present, all
classes are implemented, etc. Today I spoted a problem and made exaple project
that models this situation:

 classes.d












class A { int a; }
 templ.d












class TemplateClass(T) { static const TypeInfo ti = typeid(T); }
 core.d












private import templ; private import classes; int main(char[][] args) { TemplateClass!(A) tc = new TemplateClass!(A)(); return 0; }
 SConstruct













Build output is: D:\dtest>scons scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... C:/dmd/bin/dmd -I. -IC:\dmd\src\phobos -c -ofclasses.obj classes.d C:/dmd/bin/dmd -I. -IC:\dmd\src\phobos -c -ofcore.obj core.d C:/dmd/bin/dmd -I. -IC:\dmd\src\phobos -c -oftempl.obj templ.d C:/dmd/bin/dmd -oftest.exe core.obj templ.obj classes.obj C:\dmd\bin\..\..\dm\bin\link.exe core+templ+classes,test.exe,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved core.obj(core) Error 42: Symbol Undefined __init_20TypeInfo_C7classes1A --- errorlevel 1 scons: *** [test.exe] Error 1 scons: building terminated because of errors. As you can see linker reports every class that will be transmited to TemplateClass as template parameter as undefined symbol. static const TypeInfo ti = typeid(T); line invokes this strange behaviour. I think this is a bug. But maybe I didn't understand something?

Jan 20 2005
prev sibling parent reply "Huang Yicheng" <zergbird msn.com> writes:
Can you give me the url for download DIDE?
I went to the mainpage but found nothing to download

"Victor Nakoryakov" <Victor_member pathlink.com> wrote in message 
news:cso8v1$2jnh$1 digitaldaemon.com...
 Hi all.

 Until last week I used DIDE for developing my project. Because project 
 growth
 recompiling it each time became annoying, so I decide to use PN2 as editor 
 and
 SCons system as builder. I wrote SConscripts, etc, etc, and try to 
 compile. All
 fine, all compiles but I've got some errors on link step. Something ala

 src\rame\graphics\rsgl.obj(rsgl)
 Error 42: Symbol Undefined
 __init_52TypeInfo_C4rame8graphics12rendertarget12ColorBuffer

 I could not understand the reason for several days: all modules present, 
 all
 classes are implemented, etc. Today I spoted a problem and made exaple 
 project
 that models this situation:

 classes.d












class A { int a; }
 templ.d












class TemplateClass(T) { static const TypeInfo ti = typeid(T); }
 core.d












private import templ; private import classes; int main(char[][] args) { TemplateClass!(A) tc = new TemplateClass!(A)(); return 0; }
 SConstruct













Build output is: D:\dtest>scons scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... C:/dmd/bin/dmd -I. -IC:\dmd\src\phobos -c -ofclasses.obj classes.d C:/dmd/bin/dmd -I. -IC:\dmd\src\phobos -c -ofcore.obj core.d C:/dmd/bin/dmd -I. -IC:\dmd\src\phobos -c -oftempl.obj templ.d C:/dmd/bin/dmd -oftest.exe core.obj templ.obj classes.obj C:\dmd\bin\..\..\dm\bin\link.exe core+templ+classes,test.exe,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved core.obj(core) Error 42: Symbol Undefined __init_20TypeInfo_C7classes1A --- errorlevel 1 scons: *** [test.exe] Error 1 scons: building terminated because of errors. As you can see linker reports every class that will be transmited to TemplateClass as template parameter as undefined symbol. static const TypeInfo ti = typeid(T); line invokes this strange behaviour. I think this is a bug. But maybe I didn't understand something?

Jan 21 2005
parent nail <nail_member pathlink.com> writes:
In article <csqgnj$2aci$1 digitaldaemon.com>, Huang Yicheng says...
Can you give me the url for download DIDE?
I went to the mainpage but found nothing to download

Check your mailbox.
Jan 21 2005