I'm using VS 2019 with vcpkg and boost 1.81
I've created a Dynamic Link Library Project (c++) and I've added the boost serialization library headers.
when I set vcpkg to use static libraries it builds fine, however if i set the "Use static Libraries" to No then I get the following compiler errors
Severity Code Description Project File Line Suppression State
Error C2491 'boost::archive::detail::archive_serializer_map<Archive>::insert': definition of dllimport function not allowed C:\dev\vcpkg\installed\x86-windows\include\boost\archive\impl\archive_serializer_map.ipp 41
Error C2491 'boost::archive::detail::archive_serializer_map<Archive>::erase': definition of dllimport function not allowed C:\dev\vcpkg\installed\x86-windows\include\boost\archive\impl\archive_serializer_map.ipp 49
Error C2491 'boost::archive::basic_binary_iprimitive<Archive,Elem,Tr>::basic_binary_iprimitive': definition of dllimport function not allowed C:\dev\vcpkg\installed\x86-windows\include\boost\archive\impl\basic_binary_iprimitive.ipp 146
Error C2491 'boost::archive::basic_binary_iprimitive<Archive,Elem,Tr>::~basic_binary_iprimitive': definition of dllimport function not allowed C:\dev\vcpkg\installed\x86-windows\include\boost\archive\impl\basic_binary_iprimitive.ipp 170
Error C2491 'boost::archive::detail::archive_serializer_map<Archive>::insert': definition of dllimport function not allowed C:\dev\vcpkg\installed\x86-windows\include\boost\archive\impl\archive_serializer_map.ipp 41
Error C2491 'boost::archive::detail::archive_serializer_map<Archive>::erase': definition of dllimport function not allowed C:\dev\vcpkg\installed\x86-windows\include\boost\archive\impl\archive_serializer_map.ipp 49
...[redacted]
what should i do to get it to build as a dynamic library?
UPDATE 2023/1/30 this issue happens only when adding the portable_binary_iarchive
and portable_binary_iarchive
files to the project. these files are not part of the standard boost library, however they are included in the examples.
you can create a CMake project, add the following commond in your CMakeLists.txt
:
set(Boost_USE_STATIC_LIBS OFF)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.