Ableton / link

Ableton Link
Other
1.09k stars 149 forks source link

'asio': ambiguous symbol #58

Closed sinosoidal closed 5 years ago

sinosoidal commented 5 years ago

Hi,

I'm having this ambiguity issue when compiling on Windows with MSVC2017.

Both Link and Asio are in my include path. Curiously this ambiguity problem doesn't happen on Mac OSX.

The only work around I have found so far was renaming Link's asio namespace to asiowrapper and updating all the references to it.

Any other way of doing this?

Thanks!

asio\include\asio/basic_io_object.hpp(222): error C2872: 'asio': ambiguous symbol asio\include\asio/impl/write_at.hpp(35): note: could be 'asio' link\include\ableton/platforms/asio/Util.hpp(28): note: or 'ableton::platforms::asio' asio\include\asio/basic_io_object.hpp(222): note: while compiling class template member function 'asio::basic_io_object<asio::detail::win_iocp_handle_service,true>::basic_io_object(asio::io_context &)' asio\include\asio/windows/overlapped_handle.hpp(81): note: see reference to function template instantiation 'asio::basic_io_object<asio::detail::win_iocp_handle_service,true>::basic_io_object(asio::io_context &)' being compiled asio\include\asio/windows/overlapped_handle.hpp(58): note: see reference to class template instantiation 'asio::basic_io_object<asio::detail::win_iocp_handle_service,true>' being compiled asio\include\asio/use_future.hpp(137): note: see reference to class template instantiation 'asio::use_future_t<std::allocator>::std_allocator_void' being compiled asio\include\asio/use_future.hpp(145): note: see reference to class template instantiation 'asio::use_future_t<std::allocator>' being compiled

fgo-ableton commented 5 years ago

Do you also use asio in your code? Link already includes its asio dependecides. So there should be no need to manually include it for Link itself.

sinosoidal commented 5 years ago

Thanks for your reply. Since Ableton Link is a header based source, I'm just including it. I'm not compiling it and referencing it as a lib. In this case, I also need to include asio in the include path. How would you recommend doing it?

fgo-ableton commented 5 years ago

Including the headers sounds just right. You could have a look at ConfigureCompileFlags.cmake to see how the MSVC project is set up. Or maybe generate a Link project using cmake and compare it to yours?

sinosoidal commented 5 years ago

I use Qt. I can make a Qt project to demonstrate the issue. My solution was to rename asio to asiowrapper in the ableton side of things. Obviously I don't want to stay here to avoid conflicts and extra work in the future.

fgo-ableton commented 5 years ago

You mean Qt Creator? I don't have any experiences with it and afaik cmake can not generate projects for it. Renaming the wrapper is defiantly not a good solution - and this should not be necessary. Maybe it is worth trying to compare the includes in a MSVC project generated by cmake with what you set up.

sinosoidal commented 5 years ago

@fgo-ableton sorry for the late reply.

I don't know what you mean with "afaik cmake can not generate projects for it." as I don't intend to use cmake at all. For link and asio I refer them as external git modules in my source dir and use the Qt project file to include them as necessary using the INCLUDE_PATH qmake var.

I have made a simple Qt project to demonstrate the problem. This demo project is only prepared to be build on Windows as I don't have this problem on other platforms with the same architecture of includes (iOS, Android, Mac OSX).

You can find the project attached.

Thanks and HAPPY NEW YEAR!

link_asio_ambiguous_symbol.zip

cdi-ableton commented 5 years ago

Happy new year, @sinosoidal!

I think the using-directives are causing the name lookup problem. Try removing

using namespace ableton;
using namespace platforms;
sinosoidal commented 5 years ago

@cdi-ableton happy new year to you too! :)

Your suggestion ended with the problem. That's great! 👍

Thanks for your help. I will close the issue now.

Best