Opened 11 years ago

Last modified 11 years ago

#6688 new Feature Requests

better support for exporting symbols from DLL

Reported by: arvid@… Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost Development Trunk Severity: Problem
Keywords: export symbol Cc:

Description

Currently asio/detail/config.hpp only supports exporting symbols from compilers that supports declspec (i.e. msvc). In order to support many more compilers, including GCC (and gcc compatibles) and sun studio etc. The config header could be simplified to use boost config's BOOST_SYMBOL_EXPORT/IMPORT macro.

Patch against trunk is attached.

Attachments (2)

export_symbols.diff (1.2 KB ) - added by arvid@… 11 years ago.
patch to support exporting symbols in compilers other than msvc
asio_export.diff (1.5 KB ) - added by arvid@… 11 years ago.
updated patch to also export io_service::service

Download all attachments as: .zip

Change History (4)

by arvid@…, 11 years ago

Attachment: export_symbols.diff added

patch to support exporting symbols in compilers other than msvc

comment:1 by arvid@…, 11 years ago

actually. with some more testing on darwin, it turns out there's one more change for this to work with GCC. the io_service::service type is not exported, only some of its member functions. My understanding of MSVC's export semantics is that all type metadata (specifically type_info and vtables) are always exported, whereas on GCC, you have to explicitly export a type for its metadata to be exported. I think the io_service::service type should be exported for this reason (otherwise I get a link error failing to find its type_info, presumably originating from a typeid() call inside an asio header).

I'm attaching an updated patch.

by arvid@…, 11 years ago

Attachment: asio_export.diff added

updated patch to also export io_service::service

comment:2 by arvid@…, 11 years ago

for reference, this is the error message I get if I don't export io_service::service

Undefined symbols for architecture x86_64:
  "typeinfo for boost::asio::io_service::service", referenced from:
      typeinfo for boost::asio::detail::service_base<boost::asio::socket_acceptor_service<boost::asio::ip::tcp> >in setup_transfer.o
      typeinfo for boost::asio::detail::service_base<boost::asio::deadline_timer_service<libtorrent::ptime, boost::asio::time_traits<libtorrent::ptime> > >in setup_transfer.o
ld: symbol(s) not found for architecture x86_64
Note: See TracTickets for help on using tickets.