Coder Social home page Coder Social logo

Comments (13)

Lastique avatar Lastique commented on August 15, 2024 4

The problem is likely mismatch between the library you're compiling for and your linker selects. v2s_mt_posix means you're compiling for the static library of Boost.Log and the linker is probably using the shared library by default.

If you want to link with the static library, you should explicitly specify it with the full path and no -l switch in the command line (e.g. gcc foo.o /usr/lib/libboost_log.a) or make sure no shared library is found by the linker. I don't know if CMake offers an easy way to do this.

If you want to link with the shared library then you should define BOOST_LOG_DYN_LINK or BOOST_ALL_DYN_LINK. See here.

from log.

sflis avatar sflis commented on August 15, 2024 4

For any of you that have these issues when compiling against static boost libraries the issue is actually that the FindBoost module in cmake is broken (see https://gitlab.kitware.com/cmake/cmake/-/issues/20638). The dependencies set for Boost::log are wrong in the find module as Boost::log_setup depends on Boost::log not the other way around.

Unfortunately I haven't figured out a clean workaround for this. Adding the libraries (not the targets) manually in the correct order solves the linker error, however it screws up the cmake configuration export.

from log.

a-r-db avatar a-r-db commented on August 15, 2024 4

The following worked for me.

cmake_minimum_required(VERSION 3.16)
project(PROJECT_NAME)
set(CMAKE_CXX_STANDARD 20)

find_package(Boost 1.71 REQUIRED COMPONENTS log_setup log)
add_executable(PROJECT_NAME main.cpp)

target_link_libraries(PROJECT_NAME ${Boost_LIBRARIES})

from log.

bkda avatar bkda commented on August 15, 2024

Need your help,many thanks.

from log.

bkda avatar bkda commented on August 15, 2024

I tried many ways, even specify full path, /usr/local/lib/libboost_log_setup.a /usr/local/lib/libboost_log.a still don't work.

It wastes me too much time.

from log.

Lastique avatar Lastique commented on August 15, 2024

Does the linker issue any errors, like when it can't find the libraries you specify? If not, can you see the symbol names in the static libraries? In particular, the namespace name in the symbols is of interest. Using the link I posted, you can see the difference in the namespace names and adjust your config accordingly.

from log.

bkda avatar bkda commented on August 15, 2024

No, I can't see any errors, it just tells me Undefined symbols for architecture x86_64.

I added add_definitions(-DBOOST_LOG_DYN_LINK) into cmakelists.txt and it works on linux but on my mac ,it still doesn't work.

from log.

Lastique avatar Lastique commented on August 15, 2024

Sorry, but I can't suggest anything helpful except to inspect your static libraries to see what's wrong with them. As a wild guess, is it possible that the libraries are 32-bit?

You can also try building Boost yourself.

from log.

enhering avatar enhering commented on August 15, 2024

Same on my MAC. Tried all solutions to fix it, but could not. I'm using Sierra and Boost 1.70.

from log.

Divyank004 avatar Divyank004 commented on August 15, 2024

Is anyone able to find the solution for the above issue in MAC

from log.

amosialek avatar amosialek commented on August 15, 2024

I've added add_definitions(-DBOOST_LOG_DYN_LINK) and still getting the same error.
BOOST 1.71.0
Ubuntu 18.04.3

CMakeLists:

`
cmake_minimum_required(VERSION 3.10.0)

add_executable(Graphessor main.cpp)
find_package(Threads REQUIRED)
target_link_libraries (Graphessor Threads::Threads)
add_definitions(-DBOOST_LOG_DYN_LINK)
target_link_libraries (Graphessor Models)
target_link_libraries (Graphessor IO)
target_link_libraries (Graphessor Logic)
find_package(Boost COMPONENTS program_options REQUIRED)
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
TARGET_LINK_LIBRARIES( Graphessor ${Boost_LIBRARIES} )
`

from log.

luke-pefi avatar luke-pefi commented on August 15, 2024

@a93h 's solution didn't work for me. But this did the trick:

find_package(Boost 1.73 REQUIRED COMPONENTS log)
find_library(loglib libboost_log.a 3rdparty/boost_1_73_0/stage/lib)
target_link_libraries(Boost::log INTERFACE ${loglib})

This adds an additional instance of libboost_log at the end of the compiler line when linking.
Obviously change libboost_log.a to boost_log if you want the shared library version, and put your own path to the boost libraries dir.

from log.

adityaprakash75 avatar adityaprakash75 commented on August 15, 2024

Anyone got any solid fix for this on MAC??

from log.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.