Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 4,103
    • Issues 4,103
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 14
    • Merge requests 14
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMakeCMake
  • CMakeCMake
  • Issues
  • #19315
Closed
Open
Issue created May 29, 2019 by Arthur Anderson@arthuranderson3

dyld: Library not loaded: libboost_filesystem.dylib Referenced from: ...Reason: image not found

When I build main with dynamic link to boost log. I get

dyld: Library not loaded: libboost_filesystem.dylib
  Referenced from: /Users/arthuranderson/Documents/work/edx/algo/cmake-build-debug/algo_main
  Reason: image not found. 

I am expecting main to build and run.

Environment:

OS: OSX 10.14.2
XCode: 10.1

algo/
  cmake/
    CMakeList.Boost.txt.in
  src/
    main.cpp
  test/
    versionUnitTests.cpp

  CMakeLists.txt

Boost is brought in using ExternalProject_add.

It downloads, extracts and builds all the libs needed. They show up correctly in the CMakeCache.txt. The build and download happens in the CMAKE_CURRENT_BINARY_DIR The libraries are located in CMAKE_CURRENT_BINARY_DIR/boost/lib

CMakelist.Boost.txt.in contents are...

cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
#---------------------------------------------------------------------------
# Get and build boost
include(ExternalProject)
message("----- building boost ----")
message( ${CMAKE_BUILD_TYPE})

ExternalProject_Add(Boost
        URL https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.bz2
        URL_HASH SHA256=430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778
        PREFIX ${CMAKE_CURRENT_BINARY_DIR}/boost
        UPDATE_COMMAND ""
        LOG_DIR ${CMAKE_CURRENT_BINARY_DIR}/boost-log
        DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/boost-download
        SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/boost-src
        BUILD_IN_SOURCE 1
        CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/boost-src/bootstrap.sh --prefix=${CMAKE_CURRENT_BINARY_DIR}/boost
        BUILD_COMMAND ./b2 install variant=debug -j8 link=shared --with-filesystem --with-system --with-date_time --with-thread --with-regex --with-log
        INSTALL_COMMAND ""
        TEST_COMMAND ""
        LOG_DOWNLOAD 1
        LOG_CONFIGURE 1
        LOG_BUILD 1
        LOG_INSTALL 1
        LOG_LOG_MERGED_STDOUTERR 1
        )

The CMakeLists.txt that uses this in configure_file

cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

cmake_policy(SET CMP0048 NEW)
project(algo_main VERSION 0.1.1 )

set(CMAKE_CXX_STANDARD 14)

# Boost
set(Boost_DEBUG 1)
configure_file(cmake/CMakeList.Boost.txt.in boost-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
        RESULT_VARIABLE result
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/boost-download)
if (result)
    message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif ()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
        RESULT_VARIABLE result
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/boost-download)
if (result)
    message(FATAL_ERROR "Build step for boost failed: ${result}")
endif ()
set(BOOST_ROOT ${CMAKE_CURRENT_BINARY_DIR}/boost )
find_package(Boost 1.70.0 EXACT REQUIRED COMPONENTS filesystem system date_time thread regex log)


# VERSION
configure_file(src/version/version_defs.h.in generated/version_defs.h @ONLY)

add_executable(algo_main
        src/main.cpp src/version/Version.cpp src/util/Logger.cpp src/util/Logger.h)
target_include_directories(algo_main
        PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/generated )
if( Boost_FOUND )
    target_include_directories(algo_main
            PRIVATE ${Boost_INCLUDE_DIR})
    target_link_libraries(algo_main ${Boost_LIBRARIES})
    target_link_directories(algo_main
            PRIVATE ${Boost_LIBRARY_DIR})
endif( Boost_FOUND )

I think this maybe related to another post, where they found that xcode could not find libraries that were not installed in the global location. Any suggestions could help. I would rather stay away from installing in /usr/local/bin and keep the libraries local to the project.

Thanks Arthur

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking