Skip to content

Fail to build HelloWorld on Macos. #134

@i11010520

Description

@i11010520

[flake.nix]:

{
  inputs.nixpkgs.url = "nixpkgs";

  outputs = { self, nixpkgs,  ... }: let
    system = "aarch64-darwin";
    pkgs = nixpkgs.legacyPackages.${system};
    in
    {
    devShells = {
      ${system}.default = pkgs.mkShell {
        buildInputs = [
           pkgs.openssl
          pkgs.gcc
          pkgs.boost
          pkgs.cmake
        ];

      };
    };
  };
}

[CMakeLists.txt]:

cmake_minimum_required(VERSION 3.14)
project(HelloWorld)

# Find Lithium and its dependencies.
find_package(OpenSSL REQUIRED)
# Find Boost and its components.
find_package(Boost REQUIRED COMPONENTS context system)

# Include the locally installed Lithium headers.
include_directories(${CMAKE_SOURCE_DIR}/lithium/include)

# Add the executable.
add_executable(demo demo.cc)

# Link dependencies.
target_link_libraries(demo PRIVATE Boost::boost OpenSSL::SSL OpenSSL::Crypto)

[demo.c]

#include <lithium_http_server.hh>

int main() {
  li::http_api api;

  api.get("/hello") = [&](li::http_request &request,
                          li::http_response &response) {
    response.write("hello world.");
  };

  li::http_serve(api, 3000);
  return 0;
}

Error:

❯ make
[ 50%] Building CXX object CMakeFiles/demo.dir/demo.cc.o
[100%] Linking CXX executable demo
Undefined symbols for architecture arm64:
  "boost::context::stack_traits::default_size()", referenced from:
      void li::async_reactor::event_loop<auto li::http_async_impl::make_http_processor<void li::http_serve<>(li::api<li::http_reque
st, li::http_response>, int)::'lambda'(auto&)>(auto)::'lambda'(auto&)>(int, auto) in demo.cc.o
  "boost::context::detail::jump_fcontext(void*, void*)", referenced from:
      void li::async_reactor::event_loop<auto li::http_async_impl::make_http_processor<void li::http_serve<>(li::api<li::http_reque
st, li::http_response>, int)::'lambda'(auto&)>(auto)::'lambda'(auto&)>(int, auto) in demo.cc.o
      void* boost::context::detail::create_context1<boost::context::detail::record<boost::context::continuation, boost::context::ba
sic_fixedsize_stack<boost::context::stack_traits>, void li::async_reactor::event_loop<auto li::http_async_impl::make_http_processor
<void li::http_serve<>(li::api<li::http_request, li::http_response>, int)::'lambda'(auto&)>(auto)::'lambda'(auto&)>(int, auto)::'la
mbda'(boost::context::continuation&&)>, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, void li::async_reactor
::event_loop<auto li::http_async_impl::make_http_processor<void li::http_serve<>(li::api<li::http_request, li::http_response>, int)
::'lambda'(auto&)>(auto)::'lambda'(auto&)>(int, auto)::'lambda'(boost::context::continuation&&)>(boost::context::basic_fixedsize_st
ack<boost::context::stack_traits>&&, void li::async_reactor::event_loop<auto li::http_async_impl::make_http_processor<void li::http
_serve<>(li::api<li::http_request, li::http_response>, int)::'lambda'(auto&)>(auto)::'lambda'(auto&)>(int, auto)::'lambda'(boost::c
ontext::continuation&&)&&) in demo.cc.o
      void boost::context::detail::context_entry<boost::context::detail::record<boost::context::continuation, boost::context::basic
_fixedsize_stack<boost::context::stack_traits>, void li::async_reactor::event_loop<auto li::http_async_impl::make_http_processor<vo
id li::http_serve<>(li::api<li::http_request, li::http_response>, int)::'lambda'(auto&)>(auto)::'lambda'(auto&)>(int, auto)::'lambd
a'(boost::context::continuation&&)>>(boost::context::detail::transfer_t) in demo.cc.o
      li::async_fiber_context::ssl_handshake(std::__1::unique_ptr<li::ssl_context, std::__1::default_delete<li::ssl_context>>&) in 
demo.cc.o
      li::async_fiber_context::write(char const*, int) in demo.cc.o
      li::async_fiber_context::read(char*, int) in demo.cc.o
  "boost::context::detail::make_fcontext(void*, unsigned long, void (*)(boost::context::detail::transfer_t))", referenced from:
      void* boost::context::detail::create_context1<boost::context::detail::record<boost::context::continuation, boost::context::ba
sic_fixedsize_stack<boost::context::stack_traits>, void li::async_reactor::event_loop<auto li::http_async_impl::make_http_processor
<void li::http_serve<>(li::api<li::http_request, li::http_response>, int)::'lambda'(auto&)>(auto)::'lambda'(auto&)>(int, auto)::'la
mbda'(boost::context::continuation&&)>, boost::context::basic_fixedsize_stack<boost::context::stack_traits>, void li::async_reactor
::event_loop<auto li::http_async_impl::make_http_processor<void li::http_serve<>(li::api<li::http_request, li::http_response>, int)
::'lambda'(auto&)>(auto)::'lambda'(auto&)>(int, auto)::'lambda'(boost::context::continuation&&)>(boost::context::basic_fixedsize_st
ack<boost::context::stack_traits>&&, void li::async_reactor::event_loop<auto li::http_async_impl::make_http_processor<void li::http
_serve<>(li::api<li::http_request, li::http_response>, int)::'lambda'(auto&)>(auto)::'lambda'(auto&)>(int, auto)::'lambda'(boost::c
ontext::continuation&&)&&) in demo.cc.o
  "boost::context::detail::ontop_fcontext(void*, void*, boost::context::detail::transfer_t (*)(boost::context::detail::transfer_t))
", referenced from:
      void li::async_reactor::event_loop<auto li::http_async_impl::make_http_processor<void li::http_serve<>(li::api<li::http_reque
st, li::http_response>, int)::'lambda'(auto&)>(auto)::'lambda'(auto&)>(int, auto) in demo.cc.o
      boost::context::continuation::~continuation() in demo.cc.o
      li::fiber_exception::~fiber_exception() in demo.cc.o
      std::__1::vector<boost::context::continuation, std::__1::allocator<boost::context::continuation>>::__append(unsigned long) in
 demo.cc.o
      void boost::context::detail::context_entry<boost::context::detail::record<boost::context::continuation, boost::context::basic
_fixedsize_stack<boost::context::stack_traits>, void li::async_reactor::event_loop<auto li::http_async_impl::make_http_processor<vo
id li::http_serve<>(li::api<li::http_request, li::http_response>, int)::'lambda'(auto&)>(auto)::'lambda'(auto&)>(int, auto)::'lambd
a'(boost::context::continuation&&)>>(boost::context::detail::transfer_t) in demo.cc.o
      boost::context::detail::record<boost::context::continuation, boost::context::basic_fixedsize_stack<boost::context::stack_trai
ts>, void li::async_reactor::event_loop<auto li::http_async_impl::make_http_processor<void li::http_serve<>(li::api<li::http_reques
t, li::http_response>, int)::'lambda'(auto&)>(auto)::'lambda'(auto&)>(int, auto)::'lambda'(boost::context::continuation&&)>::run(vo
id*) in demo.cc.o
      void li::async_reactor::event_loop<auto li::http_async_impl::make_http_processor<void li::http_serve<>(li::api<li::http_reque
st, li::http_response>, int)::'lambda'(auto&)>(auto)::'lambda'(auto&)>(int, auto)::'lambda'(boost::context::continuation&&)::operat
or()(boost::context::continuation&&) const in demo.cc.o
      ...
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/demo.dir/build.make:102: demo] Error 1
make[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/demo.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions