Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] plugin dll: What project settings arereally needed?
From: Robert Ramey (ramey_at_[hidden])
Date: 2011-01-28 12:04:33


Note - real response, the previous time I accidently hit return.

Georg Gast wrote:
> Hi!
>
> Currently i'm trying to understand serialization via base pointer in
> a dll.
> My environment:
> - Windows XP SP3
> - MS Visual Studio 2010 Prof (German)
> - Boost: 1.45.0
>
> To try that i created 2 projects in one solution: test.exe (like
> test_dll_plugin) and test_plugin.dll (like dll_polymorphic_derivied2).
> Copied these files from boost/libs/serialization/(test|examples).
>
> Files in test.exe project (console app):
> - polymorphic_base.hpp
> - test_tools.hpp
> - text_archives.hpp
>
> Files in test_plugin.dll (standard win32 dll):
> - polymorphic_base.hpp
> - test_dll_plugin.cpp
> - polymorphic_derived2.cpp
>
> shared files:
> - test_decl.hpp
> - polymorphic_base.hpp
>
> Then i tried to copy the project settings to know the exact required
> settings:
>
> test.exe:
> ---------
> Preprozessor:
> WIN32;(_DEBUG|NDEBUG);_CONSOLE;BOOST_LIB_DIAGNOSTIC=1;BOOST_ALL_DYN_LINK=1
>
> C++:
> Checking of small types: Yes /RTCc
> Funktionlevel-Linking aktiv: No /Gy-
> Run time type info: yes / GR
> systeminternal functions active: yes /Oi
> Runtime Library: Multithreaded(-Debug)-DLL (/MD|/MDd)
>
> test.dll:
> ---------
> Preprozessor:
> WIN32;(_DEBUG|NDEBUG);BOOST_ALL_DYN_LINK=1;BOOST_LIB_DIAGNOSTIC=1;_WINDOWS;_USRDLL;PLUGINDLL_EXPORTS
>
> C++:
> minimal recompilation: No /Gm-
> complete runtimechecking (Vollständige Laufzeitüberprüfung): Standard
> Run time type info: yes / GR
> Runtime Library: Multithreaded(-Debug)-DLL (/MD|/MDd)
>
> Now my questions:
>
> First Question:
> Are the above mentioned project settings for the exe and the dll
> really right and complete? Or is something not needed or missing?

They are as far as I know. I tested with them. Did this not work for you?
If not, what happened? Note that you might have to change some
pathnames from mine if you get link errors.

> Second question:
> In my real project the dll should be able to provide derivied class
> dependant MFC Objects (Views/Dialogs) which are then shown in the exe.
> So: Is that (serialization through basepointer in dll) possible with
> a MFC extension library or do i need to create a MFC gui dll and a
> "polymorphic_derived2.dll"?
> Hope that is understandable ;)

lol - I think I understand what you're getting at. I don't know how much
I can say without a specific case, but here goes.

There are two kinds of libraries static and dynamic.

The static one supplies code which a compile time analysis deems is
required - and ONLY that
code. This is the main attraction of a static library.

The dynamic one is loaded at runtime so it doesn't "know" which functions in
the library
will be called - so it includes ALL the code.

Some C++ features (ie calling through virtual base class) refer to code not
explicitly
named until runtime. This can make the static library approach fail which
the dynamic
will work. This can be extremely confusing. Mix in templates, and it's
even
more confusing.

Ultimately, one will have to consider how the linker works in light of the
specific
program in question and tweak things accordingly. There is not "magic
bullet"
such as "just change the project settings". You just have to spend some
time
organizing the code to be sure that all the correct code gets included.

I don't know if that's helpful, but I'm not sure of what else to say here.

Robert Ramey

>
> Best Regards
>
> Georg Gast


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net