[serialization] plugin dll: What project settings are really needed?
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? 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 ;) Best Regards Georg Gast
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?
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 ;)
Best Regards
Georg Gast
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
Am 28.01.2011 18:04, schrieb Robert Ramey: Hello Robert!
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. Yes it did work for me. I got only one warning that polymorphic_base is no dll-interface, but that occured even in your test projects.
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.
...intersting stuff about libs and linkers... Thank you Robert for your answers!
On the boost-users mailing list are some questions and testcode which did not work which tried to do that kind of stuff. As far as i remember, your answer was, that it was important to get the project settings right. So i tried to do my homework ;) and made an example. It wasn't clear to me, what project settings are needed. First i tried with my classes, but it did not work. Then i copied your files and it did not work. Only after coping your settings changed that. May it be possible to add an explanation which requirements are needed for serialization via abstract interfaces in dlls in the documentation of the serialization library? Thanks again! Georg
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Georg Gast Sent: Friday, January 28, 2011 3:38 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] plugin dll: What project settingsarereally needed?
Am 28.01.2011 18:04, schrieb Robert Ramey: Hello Robert!
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. Yes it did work for me. I got only one warning that polymorphic_base is no dll-interface, but that occured even in your test projects.
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.
...intersting stuff about libs and linkers... Thank you Robert for your answers!
On the boost-users mailing list are some questions and testcode which did not work which tried to do that kind of stuff. As far as i remember, your answer was, that it was important to get the project settings right. So i tried to do my homework ;) and made an example. It wasn't clear to me, what project settings are needed. First i tried with my classes, but it did not work. Then i copied your files and it did not work. Only after coping your settings changed that. May it be possible to add an explanation which requirements are needed for serialization via abstract interfaces in dlls in the documentation of the serialization library?
George, Robert's solution was to change the linking of the project to pull in the serialization dll instead of linking it in statically in both projects. Unfortunately I can't release my software that way so it's a nonstarter for me :( It looks like in order for multiple DLLs to work you HAVE to link in the serialization library as a DLL otherwise it just won't work. Jeremy
George,
Robert's solution was to change the linking of the project to pull in the serialization dll instead of linking it in statically in both projects. Unfortunately I can't release my software that way so it's a nonstarter for me :(
It looks like in order for multiple DLLs to work you HAVE to link in the serialization library as a DLL otherwise it just won't work.
You CAN get around this. BUT you have to do some backflips to make it work. Basically it includes making a module for your main exe which explictly refers to the derived classes by name (and likely their functions also). This will make sure they get sucked into the main executable. BUT, the microsoft linker is soooooooooooooo smart. It is very successful at elminating code it doesn't think is actually invoked. Worse, it's different between debug and release mode. To make this work, you have to go through your project settings or link switches or "decl" statements to make sure that code isn't purged even though it doesn't look like it's used. In the serialization library certain code is marked with decl("export") in the main exe. This doesn't look like it makes sense - and it doesn't except for the fact that the side effect of this is that the code isn't stripped. See the "force_include.hpp" to see how this is done. Robert Ramey
Jeremy
Thank you Robert for your answers!
No problem - I love to talk!
On the boost-users mailing list are some questions and testcode which did not work which tried to do that kind of stuff. As far as i remember, your answer was, that it was important to get the project settings right. So i tried to do my homework ;) and made an example. It wasn't clear to me, what project settings are needed. First i tried with my classes, but it did not work. Then i copied your files and it did not work. Only after coping your settings changed that. May it be possible to add an explanation which requirements are needed for serialization via abstract interfaces in dlls in the documentation of the serialization library?
Great idea, please write this up so I can add it to the docs. Thanks for your help. Robert Ramey
participants (3)
-
Georg Gast
-
Kolb, Jeremy
-
Robert Ramey