sccn / liblsl

C++ lsl library for multi-modal time-synched data transmission over the local network
Other
107 stars 63 forks source link

Can't link to static liblsl due to missing asio #171

Open cboulay opened 2 years ago

cboulay commented 2 years ago

I'm using a pretty uncommon config and I haven't tested in other environments, so this might not be a general problem.

Macbook Pro M1Pro, MacOS 12.4, CLion with make and ninja + clang.

I'm fetching LSL using the following cmake snippet:

FetchContent_Declare(lsl
        GIT_REPOSITORY https://github.com/sccn/liblsl.git
        GIT_TAG a3322ae32d3a9da1d6dd8c591007ee209e84f38b
)
set(LSL_BUILD_STATIC ON CACHE INTERNAL "")
FetchContent_MakeAvailable(lsl)

During building, compiling works fine but then the linker gives this error:

: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  {list of objects} -o {binary}  _deps/lsl-build/liblsl.a  /opt/homebrew/lib/libportaudio.dylib  -lSystem && :
Undefined symbols for architecture arm64:
  "std::logic_error::what() const", referenced from:
      vtable for asio::invalid_service_owner in liblsl.a(stream_outlet_impl.cpp.o)
      vtable for asio::service_already_exists in liblsl.a(stream_outlet_impl.cpp.o)
      vtable for asio::invalid_service_owner in liblsl.a(tcp_server.cpp.o)
      vtable for asio::service_already_exists in liblsl.a(tcp_server.cpp.o)

(and several more pages like that)

If I change LSL_BUILD_STATIC to OFF then everything works fine, but of course I have to ship liblsl with my project binaries.

tstenner commented 1 year ago

Aside from the obligatory "I don't have a Mac" it looks to me as if the asio symbols are there, but depend on exported C++ symbols (which shouldn't happen). Asio should have an option controlling which symbols get exported, i.e. what ASIO_DECL in thirdparty/asio/asio/detail/config.hpp expands to.