Comments (13)
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.
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.
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.
Need your help,many thanks.
from log.
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.
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.
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.
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.
Same on my MAC. Tried all solutions to fix it, but could not. I'm using Sierra and Boost 1.70.
from log.
Is anyone able to find the solution for the above issue in MAC
from log.
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.
@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.
Anyone got any solid fix for this on MAC??
from log.
Related Issues (20)
- Undesired time based rotation HOT 3
- Separating loggers and sinks HOT 8
- compilation error in set_formatter method HOT 2
- Combining expressions with parse_filter
- Logger is unbuffered HOT 3
- Detected memory leaks when use boost.log in sharted library. HOT 3
- log lib failed to build due to ERROR: AddressSanitizer: allocator is out of memory trying to allocate on MSVC in asan mode HOT 1
- logging may substantially exceed total_size HOT 9
- Build for Android fails with "error: unable to find library -lrt" HOT 2
- clang-15 warning: definition of implicit copy assignment operator for 'value_ref<jb::severity_level>' is deprecated because it has a user-declared copy constructor
- Performance issue: Boost.Log does a huge work when filtering records HOT 4
- Redirect log records to specific sink only HOT 4
- Max file rotating under the same target directory HOT 1
- BOOST_LOG_TRIVIAL cannot find overloaded `operator<<()` when it's declared in global scope HOT 2
- using BOOST_LOG_TRIVIAL << with string greater than max_size_decor results in bufferoverlfow detected HOT 3
- An infinite loop occurs when boost writes to the log file HOT 4
- Timezone information with text file backend HOT 2
- Boost.Log rotation may throw boost::filesystem::filesystem_error HOT 10
- How to add timezone info for log entries and log filename HOT 3
- Formatting TimeStamp HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from log.