Assignment of boost::dll::import_symbol to boost::shared_ptr fails to compile
Yuri via Boost-users <[email protected]> Fri, 13 Jun 2025 20:01:04 -0700
| Newsgroups | gmane.comp.lib.boost.user |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--===============0551090129335829040==
Content-Type: multipart/alternative;
boundary="------------DVwlxUjeg48m7uwtiAz60DLg"
Content-Language: en-US
This is a multi-part message in MIME format.
--------------DVwlxUjeg48m7uwtiAz60DLg
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
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
--------------DVwlxUjeg48m7uwtiAz60DLg
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>I've encountered the compilation error with this program with <span
style="font-family:monospace"><span
style="color:#000000;background-color:#ffffff;">boost-libs-1.88.0</span></span>:</p>
<p><br>
</p>
<p><span style="font-family:monospace"><span
style="color:#000000;background-color:#ffffff;">#include
<boost/dll/import.hpp></span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">#include
<boost/shared_ptr.hpp></span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<br>
<span style="color:#000000;background-color:#ffffff;">class API
{</span><span style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">public:</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">
API() { }</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">};</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<br>
<br>
<span style="color:#000000;background-color:#ffffff;">void x() {</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">
boost::shared_ptr<API> pluginInterface;</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;"> </span><span
style="color:#000000;background-color:#ffffff;"> </span><br>
<span style="color:#000000;background-color:#ffffff;">
pluginInterface =
boost::dll::import_symbol<API>("path", "name");</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">}</span><br>
<span style="color:#000000;background-color:#ffffff;">
</span><br>
</span></p>
<p><span style="font-family:monospace"><br>
</span></p>
<p><span style="font-family:monospace">The error:</span></p>
<p><span style="font-family:monospace"><span
style="color:#000000;background-color:#ffffff;">$ c++
-std=c++20 -c s.cpp -I /usr/local/include/</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">s.cpp:13:21:
error: no viable overloaded '='</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;"> 13 |
pluginInterface =
boost::dll::import_symbol<API>("path", "name");</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;"> |
~~~~~~~~~~~~~~~ ^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">/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</span><br>
d::shared_ptr<API>') to 'const shared_ptr<API>' for
1st argument<span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;"> 407 |
shared_ptr & operator=( shared_ptr const & r )
noexcept</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;"> |
^ ~~~~~~~~~~~~~~~~~~~~</span><br>
<span style="color:#000000;background-color:#ffffff;">
</span><br>
</span></p>
<p><span style="font-family:monospace"><br>
</span></p>
<p><span style="font-family:monospace">Compiler: clang-19, but
gcc-12 fails in a similar way.</span></p>
<p><span style="font-family:monospace"><br>
</span></p>
<p><span style="font-family:monospace">It seems that such assignment
should work.</span></p>
<p><span style="font-family:monospace"><br>
</span></p>
<p><span style="font-family:monospace">This error was originally
found in the Dakota project
(<a class="moz-txt-link-freetext" href="https://github.com/snl-dakota/dakota">https://github.com/snl-dakota/dakota</a>).</span></p>
<p>This error prevents the Dakota project from compiling.</p>
<p><br>
</p>
<p>Thanks,</p>
<p>Yuri</p>
</body>
</html>
--------------DVwlxUjeg48m7uwtiAz60DLg--
--===============0551090129335829040==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Boost-users mailing list
[email protected]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
--===============0551090129335829040==--