Hey Zaroth, This isn't actually a template specialization problem. It is actually a linker problem. That is, the way that those functions are specialized and explicitly instantiated is correct and the symbols appear correctly in the libwesnoth.a archive.
So, I think the actual problem is due to a slight subtlety in the linking. We basically link in the order: libwesnoth_extras.a libwesnoth_core.a libwesnoth.a (with some other stuff mixed in). Now, with the GNU ld linker, these are linked in that order and after linking a library unneeded symbols are discarded. Now, game_controller.cpp is in _extras, util.cpp is in _core, and hotkeys.cpp and image_modifications.cpp are in libwesnoth.a. It seems that the only use of those lexical_casts in _extras come from game_controller.cpp:128 and so by removing that line, the symbols are discarded after linking in libwesnoth_core, and then are not present when linking in libwesnoth. Two simple solutions that seem to work for me are either swapping the order of linking libwesnoth_core.a and libwesnoth.a, or moving util.cpp to libwesnoth.a. I personally prefer swapping the order of linking as I feel that _core implies that it should not depend on anything else (and thus should be linked in last). Hope that helps, Chris Hopman On Mon, May 30, 2011 at 12:19 AM, Lukasz Dobrogowski < [email protected]> wrote: > Hello, > > I encountered a weird template specialization linking problem when > coding, connected to util.hpp and util.cpp. > > Moving the template to the header didn't fix it. Obviously, it now > complains a thousand times about multiple definitions of the same template. > > Steps to reproduce: > * apply attached patch against r49705 > * wesnoth should compile > * uncomment line line 128 in game_controller.cpp ( // int fps = 0;) and > comment line 127 (the lexical_cast_default) > * wesnoth should stop compiling (linking, to be precise) at this point, > producing following error: http://pastebin.com/84PMcxjU > > Please, help: I'm not that advanced with solving C++ template problems > and it may take me quite a while until I find a solution. The bug is > certainly isolated to this one line: before commenting use of > lexical_cast_default it happens, afterwards not. > > For full information about the problem, my and Crab_ IRC discussion > about it was > http://www.wesnoth.org/irclogs/2011/05/%23wesnoth-dev.2011-05-30.log > from 0:30 to 1:54. > > Cheers, > Zaroth > > _______________________________________________ > Wesnoth-dev mailing list > [email protected] > https://mail.gna.org/listinfo/wesnoth-dev > >
_______________________________________________ Wesnoth-dev mailing list [email protected] https://mail.gna.org/listinfo/wesnoth-dev
