|
Boost : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2004-09-04 10:46:04
I assume you're using the version currently in the main CVS tree. Or are you
using the version 1.31?
I've always had this problem. It manifests itself differently with
different compiliers. In often related to linkers removing "dead code" that
really isn't dead - the linker isn't smart enough to see that in fact the
code is used. One of the ways I've found to address this is to mark certain
templates for export (dllexport). Unfortunately, the way of doing this
varies from compiler to compiler.
So, I occasionally re-run all tests in release mode to detect these
problems. Usually this is enough. Recently, I've fixed up export to work
regardless of idiosyncrasies of various compilers and I may have broken
something. I'll retest and recheck this.
Robert Ramey
>Ive been using Boosts serialization library with MSVC 7.1 (the first time
>that Ive used it). For most of my project I put the load / save function
>declaration in the class header (the .h file) and the definitions in the
>.cpp file VC 7.1 allows this for templated functions, unlike some older
>compilers. In debug mode this compiled and linked fine except for abstract
>base classes through trial and error I found that for abstract classes
>the functions had to be defined in the .h file to avoid linker errors.
>My project built fine in Debug mode and I then tried to compile / link it
>in Release mode this threw up quite a few LNK2001 errors relating to just
>a few of the serialization load / save functions in just some of the
>classes most of the classes that declared the load / save functions
>evidently linked fine (as they all did in Debug mode). After much double
>checking of the compile / link project configurations I tried the
>following:
>1. I removed the BOOST_CLASS_EXPORT(etc) declaration at the bottom of the
>.h files in which the load / save functions were not linking. On
>recompiling / linking most of the linker errors were gone, but a few
>remained.
>2. For the remaining classes that were not still not linking, I moved the
>load / save functions from the .cpp file into the .h file (these were not
>abstract classes). This fixed the remaining linker errors and my
>application compiled / linked / ran fine.
>I can't see why this occurred. I havent checked yet (its very time
>consuming to rebuild this application) but possibly option (2) would have
>worked for all the affected classes. For most of this project, the load /
>save functions remain defined in the .cpp file and clearly link fine in
>both debug and release configurations. Before someone asks, I did complete
>clean / rebuilds for both configurations anybody any ideas?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk