1

I've build boost with c++17 standard with clang on macOS Mojave when compiling my playground program that uses beast and asio I get the following error:
enter image description here

This is my make file:

cmake_minimum_required (VERSION 3.13.1)
project (Playground)

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USER_MULITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(BOOST_ROOT "/usr/local/boost-1.68.0")
set(Boost_INLCUDE_DIR "/usr/local/boost-1.68.0/include")
set(Boost_LIBRARY_DIR_RELEASE "/usr/local/boost-1.68.0/lib")

find_package(Boost 1.68.0 REQUIRED COMPONENTS system filesystem)

set(SOURCES
    src/main.cpp
    src/http_client/http_client.hpp
    src/http_client/http_client.cpp)

if(Boost_FOUND)
    include_directories("/usr/local/boost-1.68.0/include")
    add_executable (Playground ${SOURCES})
    set_property(TARGET Playground PROPERTY CXX_STANDARD 17)
    target_include_directories(Playground PRIVATE ${BOOST_INCLUDE_DIRS})
    target_link_libraries(Playground ${BOOST_FILESYSTEM_LIBRARIES}
                                     ${BOOST_SYSTEM_LIBRARIES})
endif()

I've compiled boost with steps described in this tutorial: Compiling Boost with Clang.

Clang version:
Apple LLVM version 10.0.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0

Is there anything else I've to take into account? I've read a lot of posts, etc. where it's suggested to compile boost in the same c++ standard that should be used in the project itself.

EDIT:
Matthieu Brucher's hint with the variable names (Boost_ vs. BOOST_) did the trick. Now it's working.

Fabian
  • 492
  • 6
  • 20
  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Matthieu Brucher Dec 11 '18 at 15:16
  • Especially the last answer: you don't have the right architecture installed/built for boost, only the 32bits when you also need 64bits. – Matthieu Brucher Dec 11 '18 at 15:16
  • Also the real variable name is `Boost_SYSTEM_LIBRARY` not `BOOST_SYSTEM_LIBRARIES` – Matthieu Brucher Dec 11 '18 at 15:26

1 Answers1

0

@Matthieu Brucher's hint with the variable names (Boost_ vs. BOOST_) did the trick:

target_link_libraries(Playground ${Boost_FILESYSTEM_LIBRARY}
                                  ${Boost_SYSTEM_LIBRARY})
Fabian
  • 492
  • 6
  • 20