Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
January 20, 2005 Linker bug with "static const TypeInfo" member | ||||
---|---|---|---|---|
| ||||
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 module classes; class A { int a; } >>>>>>>>>>>> templ.d module templ; class TemplateClass(T) { static const TypeInfo ti = typeid(T); } >>>>>>>>>>>> core.d module core; private import templ; private import classes; int main(char[][] args) { TemplateClass!(A) tc = new TemplateClass!(A)(); return 0; } >>>>>>>>>>>>> SConstruct Program("test", ['core.d', 'templ.d', 'classes.d']) 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? |
January 20, 2005 Re: Linker bug with "static const TypeInfo" member | ||||
---|---|---|---|---|
| ||||
Posted in reply to Victor Nakoryakov | 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 > module classes; > > class A > { > int a; > } > >>>>>>>>>>>>> templ.d > module templ; > > class TemplateClass(T) > { > static const TypeInfo ti = typeid(T); > } > >>>>>>>>>>>>> core.d > module core; > private import templ; > private import classes; > > int main(char[][] args) > { > TemplateClass!(A) tc = new TemplateClass!(A)(); > > return 0; > } > >>>>>>>>>>>>>> SConstruct > Program("test", ['core.d', 'templ.d', 'classes.d']) > > > > 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_AaDFZv8SortedAAZi+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 |
January 21, 2005 Re: Linker bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Victor Nakoryakov | - 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 >module classes; > >class A >{ >int a; >} > >>>>>>>>>>>>> templ.d >module templ; > >class TemplateClass(T) >{ >static const TypeInfo ti = typeid(T); >} > >>>>>>>>>>>>> core.d >module core; >private import templ; >private import classes; > >int main(char[][] args) >{ >TemplateClass!(A) tc = new TemplateClass!(A)(); > >return 0; >} > >>>>>>>>>>>>>> SConstruct >Program("test", ['core.d', 'templ.d', 'classes.d']) > > > >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? > > |
January 21, 2005 Re: Linker bug with "static const TypeInfo" member | ||||
---|---|---|---|---|
| ||||
Posted in reply to Victor Nakoryakov | 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 > module classes; > > class A > { > int a; > } > >>>>>>>>>>>>> templ.d > module templ; > > class TemplateClass(T) > { > static const TypeInfo ti = typeid(T); > } > >>>>>>>>>>>>> core.d > module core; > private import templ; > private import classes; > > int main(char[][] args) > { > TemplateClass!(A) tc = new TemplateClass!(A)(); > > return 0; > } > >>>>>>>>>>>>>> SConstruct > Program("test", ['core.d', 'templ.d', 'classes.d']) > > > > 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? > > |
January 21, 2005 Re: Linker bug with | ||||
---|---|---|---|---|
| ||||
Posted in reply to Huang Yicheng | 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. |
Copyright © 1999-2021 by the D Language Foundation