
I've encountered the compilation error with this program with boost-libs-1.88.0: #include <boost/dll/import.hpp> #include <boost/shared_ptr.hpp> class API { public: API() { } }; void x() { boost::shared_ptr<API> pluginInterface; pluginInterface = boost::dll::import_symbol<API>("path", "name"); } The error: $ c++ -std=c++20 -c s.cpp -I /usr/local/include/ s.cpp:13:21: error: no viable overloaded '=' 13 | pluginInterface = boost::dll::import_symbol<API>("path", "name"); | ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/boost/smart_ptr/shared_ptr.hpp:407:18: note: candidate function not viable: no known conversion from 'boost::dll::detail::import_type<API>' (aka 'st d::shared_ptr<API>') to 'const shared_ptr<API>' for 1st argument 407 | shared_ptr & operator=( shared_ptr const & r ) noexcept | ^ ~~~~~~~~~~~~~~~~~~~~ Compiler: clang-19, but gcc-12 fails in a similar way. It seems that such assignment should work. This error was originally found in the Dakota project (https://github.com/snl-dakota/dakota). This error prevents the Dakota project from compiling. Thanks, Yuri

On Sat, Jun 14, 2025, 07:16 Yuri via Boost-users < boost-users@lists.boost.org> wrote:
I've encountered the compilation error with this program with boost-libs-1.88.0:
<...>
It seems that such assignment should work.
Boost.DLL now uses std::shared_ptr. Quoting release notes https://www.boost.org/releases/1.88.0/ :
boost::dll:import_* functions now return std::shared_ptr rather than boost::shared_ptr. Define BOOST_DLL_USE_BOOST_SHARED_PTR to restore the old behavior, however note that the macro will be removed in one of the upcomming Boost releases.
So for the above case I'd recommend to use `auto` or switch to std::shared_ptr.
participants (2)
-
Antony Polukhin
-
Yuri