Classification: Honeywell Internal
I’m using Boost 1.55
---
Steve H.
============================================================================================================================================================================================================
This message classified as Honeywell Internal
by Hickman, Steve (AdvTech) on Thursday, May 22, 2014 at 11:01:53 AM.
The above classification labels are in accordance with the Honeywell Corporate Classification Policy. The information contained in this electronic message is confidential and intended only for the use of the individual/entity named above, and the information
may be privileged. If you, the reader of this message, are not the intended recipient or an employee or agent responsible to deliver this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication
is strictly prohibited. If you have received this communication in error, please immediately notify the sender and delete the original message.
============================================================================================================================================================================================================
From: Hickman, Steve (AdvTech)
Sent: Thursday, May 22, 2014 10:56 AM
To: 'boost-users@lists.boost.org'
Subject: [serialization] Works when statically linked but not as a DLL using VS2012 on Win7 64bit [Honeywell Internal]
Classification: Honeywell Internal
I’m using Boost.Serialization on a 64 bit Win7 machine using VS 2012. I have instances from a class hierarchy that I’m serializing through a base class pointer. I’m building a 32 bit debug console application.
I’m serializing to an input text archive then extracting the stringstream and deserializing via an output text archive.
When I build the library containing the class hierarchy as a static library, I can serialize and deserialize consistently instances of any of the classes in the hierarchy multiple times. When I build the same library as a DLL, serialization/
deserialization works for some of the classes but fails consistently when deserializing one of the derived classes. I’ve checked the following things:
1)
All of the data fields of the instances are initialized. They are fundamental types (bool, int, long), std::string, a std::chrono (which has a serialization I found on the ‘Net) and one enumerated type (removing the enumerated type doesn’t
fix the problem).
2)
The serialize code is in the .cpp files (not headers) along with the instantiations for the archive I use so I don’t have multiple instantiations of the serialize methods
3)
The test driver does nothing but run the tests – so the DLL containing the library shouldn’t be loaded multiple times.
4)
The output archive is closed before I open the input archive, so there shouldn’t be characters missing at the end of the stringstream.
5)
I’m building UNICODE for both the library and the test driver, so character size shouldn’t be changing.
I know is that the Microsoft compiler does create an executable that will execute static code that is not reachable via main. I have not (to my knowledge) included static code that is unreachable via main, but I haven’t delved into the
Serialization EXPORT macros to see what exactly they are doing. I don’t know if that is a source of the problem.
When I build the library, I do get linker warnings (see examples at bottom) that I’m importing locally defined symbols. Since all of the classes in the library must be visible externally because they are used externally, they must all be
exported. Since they are part of a class hierarchy, they must be available to the other classes in the library that derive from them. I don’t know if these warnings point to the problem. I also don’t know how to get rid of them given the above.
My question is: Why is this happening? How do I fix it?
Other notes: all of the library classes have “DECL” macros that resolve to
__declspec(dllexport)
or __declspec(dllimport)
when building the dll. When I build the static library, these resolve to “” (nothing).
I’m attaching copies of relevant files. All files named “Raw*Event” are part of the library. MinimalTest.cpp is the test driver. Chrono.hpp is the serialization header that is not part of the Boost serialization library.
Compiler flags for the library when building it as a DLL:
(C/C++):
/GS /analyze- /W3 /wd"4996" /Zc:wchar_t /I"C:\GITRepos\fd_x\source" /I"C:\GITRepos\fd_x\lib\boost-aux" /I"c:\GITRepos\fd_x\lib\boost_1_55_0\\" /I"C:\GITRepos\TRACS\inc" /ZI /Gm /Od /sdl /Fd"Win32\Debug\vc110.pdb" /fp:precise /D "_WINDLL"
/D "_UNICODE" /D "UNICODE" /errorReport:prompt /doc"Win32\Debug\" /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /Fa"Win32\Debug\" /EHsc /nologo /Fo"Win32\Debug\" /Fp"Win32\Debug\Input.pch"
(Linker)
/OUT:"C:\GITRepos\fd_x\build\Win32\Debug\Input.dll" /MANIFEST /NXCOMPAT /PDB:"C:\GITRepos\fd_x\build\Win32\Debug\Input.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib"
"ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /IMPLIB:"C:\GITRepos\fd_x\build\Win32\Debug\Input.lib" /DEBUG /DLL /MACHINE:X86 /INCREMENTAL /PGD:"C:\GITRepos\fd_x\build\Win32\Debug\Input.pgd" /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/ManifestFile:"Win32\Debug\Input.dll.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"C:\GITRepos\fd_x\build\Debug\" /LIBPATH:"c:\GITRepos\fd_x\lib\TRACS" /LIBPATH:"c:\Boost\v1.55\lib-VS2012" /TLBID:1
Compiler flags for the test driver when linking the DLL:
(C/C++)
/GS /analyze- /W3 /Zc:wchar_t /I"C:\GITRepos\fd_x\source" /I"c:\GITRepos\fd_x\lib\boost_1_55_0\" /I"C:\GITRepos\fd_x\lib\boost-aux" /I"C:\GITRepos\TRACS\inc" /ZI /Gm /Od /sdl /Fd"Win32\Debug\vc110.pdb" /fp:precise /D "WIN32" /D "_DEBUG"
/D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /GR /Gd /Oy- /MDd /Fa"Win32\Debug\" /EHsc /nologo /Fo"Win32\Debug\" /Fp"Win32\Debug\InputTest-Win32.pch"
(Linker)
/OUT:"C:\GITRepos\fd_x\build\Win32\Debug\InputTest-Win32.exe" /MANIFEST /NXCOMPAT /PDB:"C:\GITRepos\fd_x\build\Win32\Debug\InputTest-Win32.pdb" /DYNAMICBASE "Input.lib" "Utilities.lib" "calsim_d.lib" "kernel32.lib" "user32.lib" "gdi32.lib"
"winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86 /INCREMENTAL /PGD:"C:\GITRepos\fd_x\build\Win32\Debug\InputTest-Win32.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker'
uiAccess='false'" /ManifestFile:"Win32\Debug\InputTest-Win32.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"C:\GITRepos\fd_x\build\Win32\Debug\" /LIBPATH:"c:\Boost\v1.55\lib-VS2012" /LIBPATH:"C:\GITRepos\TRACS\\lib" /TLBID:1
Compiler flags for the library when building it as a static library:
(C++)
/GS /analyze- /W3 /wd"4996" /Zc:wchar_t /I"C:\GITRepos\fd_x\source" /I"C:\GITRepos\fd_x\lib\boost-aux" /I"c:\GITRepos\fd_x\lib\boost_1_55_0\\" /I"C:\GITRepos\TRACS\inc" /ZI /Gm /Od /sdl /Fd"Win32\Debug\vc110.pdb" /fp:precise /D "_UNICODE"
/D "UNICODE" /errorReport:prompt /doc"Win32\Debug\" /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /Fa"Win32\Debug\" /EHsc /nologo /Fo"Win32\Debug\" /Fp"Win32\Debug\Input.pch"
(Librarian)
/OUT:"C:\GITRepos\fd_x\build\Win32\Debug\Input.lib" /NOLOGO /LIBPATH:"C:\GITRepos\fd_x\build\Win32\Debug\"
Compiler flags for the test driver when linking the static library:
(C++)
/GS /analyze- /W3 /Zc:wchar_t /I"C:\GITRepos\fd_x\source" /I"c:\GITRepos\fd_x\lib\boost_1_55_0\" /I"C:\GITRepos\fd_x\lib\boost-aux" /I"C:\GITRepos\TRACS\inc" /ZI /Gm /Od /sdl /Fd"Win32\Debug\vc110.pdb" /fp:precise /D "WIN32" /D "_DEBUG"
/D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /GR /Gd /Oy- /MDd /Fa"Win32\Debug\" /EHsc /nologo /Fo"Win32\Debug\" /Fp"Win32\Debug\InputTest-Win32.pch"
(Linker)
/OUT:"C:\GITRepos\fd_x\build\Win32\Debug\InputTest-Win32.exe" /MANIFEST /NXCOMPAT /PDB:"C:\GITRepos\fd_x\build\Win32\Debug\InputTest-Win32.pdb" /DYNAMICBASE "Input.lib" "Utilities.lib" "calsim_d.lib" "kernel32.lib" "user32.lib" "gdi32.lib"
"winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86 /INCREMENTAL /PGD:"C:\GITRepos\fd_x\build\Win32\Debug\InputTest-Win32.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker'
uiAccess='false'" /ManifestFile:"Win32\Debug\InputTest-Win32.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"C:\GITRepos\fd_x\build\Win32\Debug\" /LIBPATH:"c:\Boost\v1.55\lib-VS2012" /LIBPATH:"C:\GITRepos\TRACS\\lib" /TLBID:1
Example link warnings when building the DLL:
1>RawUIEvent.obj : warning LNK4217: locally defined symbol ??$serialize@Vbinary_iarchive@archive@boost@@@RawEvent@Input@@IAEXAAVbinary_iarchive@archive@boost@@I@Z
(protected: void __thiscall Input::RawEvent::serialize<class boost::archive::binary_iarchive>(class boost::archive::binary_iarchive &,unsigned int)) imported in function "public: static void __cdecl boost::serialization::access::serialize<class boost::archive::binary_iarchive,class
Input::RawEvent>(class boost::archive::binary_iarchive &,class Input::RawEvent &,unsigned int)" (??$serialize@Vbinary_iarchive@archive@boost@@VRawEvent@Input@@@access@serialization@boost@@SAXAAVbinary_iarchive@archive@2@AAVRawEvent@Input@@I@Z)
1>RawUIEvent.obj : warning LNK4217: locally defined symbol ??$serialize@Vbinary_oarchive@archive@boost@@@RawEvent@Input@@IAEXAAVbinary_oarchive@archive@boost@@I@Z
(protected: void __thiscall Input::RawEvent::serialize<class boost::archive::binary_oarchive>(class boost::archive::binary_oarchive &,unsigned int)) imported in function "public: static void __cdecl boost::serialization::access::serialize<class boost::archive::binary_oarchive,class
Input::RawEvent>(class boost::archive::binary_oarchive &,class Input::RawEvent &,unsigned int)" (??$serialize@Vbinary_oarchive@archive@boost@@VRawEvent@Input@@@access@serialization@boost@@SAXAAVbinary_oarchive@archive@2@AAVRawEvent@Input@@I@Z)
1> Input.vcxproj -> C:\GITRepos\fd_x\build\Win32\Debug\Input.dll
Steve Hickman
480-236-8367
============================================================================================================================================================================================================
This message classified as Honeywell Internal
by Hickman, Steve (AdvTech) on Thursday, May 22, 2014 at 10:56:21 AM.
The above classification labels are in accordance with the Honeywell Corporate Classification Policy. The information contained in this electronic message is confidential and intended only for the use of the individual/entity named above, and the information
may be privileged. If you, the reader of this message, are not the intended recipient or an employee or agent responsible to deliver this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication
is strictly prohibited. If you have received this communication in error, please immediately notify the sender and delete the original message.
============================================================================================================================================================================================================