Comments (14)
It is not intended. Please provide steps to reproduce.
from spdlog.
Hi @gabime,
This is the actual project (Eclipse eCAL) that fails building. The long CMake Options mostly turn everything off while still building enough to trigger the issue.
I know that this still isn't really a minimal setup. Creating one will cost me some time, so please tell me if you require one.
The commands target Ubuntu 22.04 but should work on other Ubuntu versions as well.
sudo apt-get -y update
sudo apt-get -y install git cmake build-essential libprotobuf-dev libprotoc-dev protobuf-compiler libyaml-cpp-dev
git clone https://github.com/eclipse-ecal/ecal.git
cd ecal
git submodule init
git submodule update
git -C thirdparty/spdlog/spdlog/ checkout v1.14.0
mkdir _build
cd _build
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DHAS_HDF5=OFF -DHAS_QT=OFF -DHAS_CURL=OFF -DHAS_CAPNPROTO=OFF -DHAS_FTXUI=OFF -DBUILD_DOCS=OFF -DBUILD_APPS=ON -DBUILD_SAMPLES=OFF -DBUILD_TIME=OFF -DBUILD_PY_BINDING=OFF -DBUILD_STANDALONE_PY_WHEEL=OFF -DBUILD_CSHARP_BINDING=OFF -DBUILD_ECAL_TESTS=OFF -DECAL_INCLUDE_PY_SAMPLES=OFF -DECAL_INSTALL_SAMPLE_SOURCES=OFF -DECAL_JOIN_MULTICAST_TWICE=OFF -DECAL_NPCAP_SUPPORT=OFF -DECAL_THIRDPARTY_BUILD_CMAKE_FUNCTIONS=ON -DECAL_THIRDPARTY_BUILD_PROTOBUF=OFF -DECAL_THIRDPARTY_BUILD_SPDLOG=ON -DECAL_THIRDPARTY_BUILD_TINYXML2=ON -DECAL_THIRDPARTY_BUILD_FINEFTP=ON -DECAL_THIRDPARTY_BUILD_CURL=OFF -DECAL_THIRDPARTY_BUILD_GTEST=OFF -DECAL_THIRDPARTY_BUILD_HDF5=OFF -DECAL_THIRDPARTY_BUILD_RECYCLE=ON -DECAL_THIRDPARTY_BUILD_TCP_PUBSUB=ON -DECAL_THIRDPARTY_BUILD_QWT=OFF -DECAL_THIRDPARTY_BUILD_YAML-CPP=OFF -DCMAKE_BUILD_TYPE=Debug
make -j8
The error printed by this is:
[ 85%] Linking CXX executable ../../../bin/ecal_sys_client
/usr/bin/ld: CMakeFiles/sys_client.dir/src/ecal_sys_client_cli.cpp.o: in function `eCAL::sys_client::EcalSysClientLogger::EcalSysClientLogger()':
/home/florian/ecal/app/sys/sys_client_core/include/sys_client_core/ecal_sys_client_logger.h:80: undefined reference to `spdlog::get(char const*)'
/usr/bin/ld: /home/florian/ecal/app/sys/sys_client_core/include/sys_client_core/ecal_sys_client_logger.h:96: undefined reference to `spdlog::get(char const*)'
collect2: error: ld returned 1 exit status
Checking out spdlog 1.13.0 instead of 1.14.0 resolves the issue.
from spdlog.
This commit (5532231) adds overloads to spdlog::get()
if C++17 or later is specified.
ABI is broken after C++17.
from spdlog.
This could be something in the project setup(e.g. linking to wrong spdlog version). Pleas provide minimal reproducible example. The steps you provided are time consuming and project specific.
from spdlog.
@tt4g: Thanks for pointing that out. As I see it, that header takes the C++ version of the library consumer into account and not the C++ version used for compiling spdlog. So consuming a C++14 compatible spdlog binary with a C++ 17 project will break.
The proper solution I guess would for example be to configure
a header file while building spdlog and saving whether the lib was built with / without C++17 API. This header file can then be included later by the public API headers, so the existence of the overloads depend on the actual library and not on the C++ standard of the consumer.
Another solution would be to set public preprocessor defines via cmake (so no configured header file is needed) that then activate those overloads for the consumer.
I checked the build logs and found the following:
spdlog is built with C++11
[ 0%] Building CXX object thirdparty/spdlog/spdlog/CMakeFiles/spdlog.dir/src/spdlog.cpp.o
cd /home/florian/ecal/_build/thirdparty/spdlog/spdlog && /usr/bin/c++ -DSPDLOG_COMPILED_LIB -I/home/florian/ecal/thirdparty/spdlog/spdlog/include -g -Wall -Wextra -std=c++11 -MD -MT thirdparty/spdlog/spdlog/CMakeFiles/spdlog.dir/src/spdlog.cpp.o -MF CMakeFiles/spdlog.dir/src/spdlog.cpp.o.d -o CMakeFiles/spdlog.dir/src/spdlog.cpp.o -c /home/florian/ecal/thirdparty/spdlog/spdlog/src/spdlog.cpp
[ 0%] Building CXX object thirdparty/spdlog/spdlog/CMakeFiles/spdlog.dir/src/stdout_sinks.cpp.o
cd /home/florian/ecal/_build/thirdparty/spdlog/spdlog && /usr/bin/c++ -DSPDLOG_COMPILED_LIB -I/home/florian/ecal/thirdparty/spdlog/spdlog/include -g -Wall -Wextra -std=c++11 -MD -MT thirdparty/spdlog/spdlog/CMakeFiles/spdlog.dir/src/stdout_sinks.cpp.o -MF CMakeFiles/spdlog.dir/src/stdout_sinks.cpp.o.d -o CMakeFiles/spdlog.dir/src/stdout_sinks.cpp.o -c /home/florian/ecal/thirdparty/spdlog/spdlog/src/stdout_sinks.cpp
ecal_sys_client is built with C++17 (gcc 11 default)
cd /home/florian/ecal/_build/app/sys/sys_client_cli && /usr/bin/cmake -E cmake_link_script CMakeFiles/sys_client.dir/link.txt --verbose=1
/usr/bin/c++ -g CMakeFiles/sys_client.dir/src/ecal_sys_client_cli.cpp.o CMakeFiles/sys_client.dir/src/ecal_sys_client_service.cpp.o -o ../../../bin/ecal_sys_client-5.13.0 -Wl,-rpath,/home/florian/ecal/_build/lib: ../../../thirdparty/spdlog/spdlog/libspdlogd.a /usr/lib/x86_64-linux-gnu/libprotobuf.so ../sys_client_core/libsys_client_core.a ../../../lib/CustomTclap/libecal_CustomTclap.a ../../../lib/ecal_utils/libecal_ecal-utils.a ../../../thirdparty/spdlog/spdlog/libspdlogd.a ../../../lib/libecal_core.so.5.13.0 ../../../contrib/ecalproto/libecal_proto.a /usr/lib/x86_64-linux-gnu/libprotobuf.so ../../../lib/libecal_core_pb.so.5.13.0 /usr/lib/x86_64-linux-gnu/libprotobuf.so ../../../lib/libecal_app_pb.so.5.13.0 /usr/lib/x86_64-linux-gnu/libprotobuf.so /usr/lib/x86_64-linux-gnu/libprotobuf.so ../../../lib/EcalParser/libEcalParser.a ../../../lib/ecal_utils/libecal_ecal-utils.a
Later it breaks when linking the binaries:
/usr/bin/ld: CMakeFiles/sys_client.dir/src/ecal_sys_client_cli.cpp.o: in function `eCAL::sys_client::EcalSysClientLogger::EcalSysClientLogger()':
/home/florian/ecal/app/sys/sys_client_core/include/sys_client_core/ecal_sys_client_logger.h:80: undefined reference to `spdlog::get(char const*)'
/usr/bin/ld: /home/florian/ecal/app/sys/sys_client_core/include/sys_client_core/ecal_sys_client_logger.h:96: undefined reference to `spdlog::get(char const*)'
from spdlog.
If I understand the issue correctly, any C++17 (or later) project that uses spdlog, which was compiled with C++11, will fail. This is indeed problematic and should be addressed in the next release of spdlog.
from spdlog.
C++ version is a tricky issue.
The C++ standard specification does not guarantee behavior when linking with libraries of different C++ versions.
So, even if spdlog thinks it has a workaround for different C++ versions, the workaround may not work as expected due to compiler incompatibility.
The best workaround I can think of is to use the same C++ version in the project with build tools such as autotools and CMake.
from spdlog.
The C++ standard specification does not guarantee behavior when linking with libraries of different C++ versions.
Thanks for pointing this out @tt4g , I wasn’t aware of this. But even so, I am thunking about reverting this commit if it causes a problem that didn’t exist before.
from spdlog.
@gabime Yes, that is the case.
spdlog downgrades itself to C++11 by default, which also isn't the nicest behavior:
Lines 31 to 34 in 238c9ff
We don't use CMAKE_CXX_STANDARD
in our projects but rather set a minimum Cxx standard via target_compile_features
. Thus, spdlog downgraded itself to C++11, even though gcc11 defaults to C++17.
@tt4g: at least on gcc and msvc it is quite common to use different cxx standards. As long as the API doesn't use unsupported features, there is no issue with linking a library that was built with a different cxx standard.
from spdlog.
@FlorianReimold In fact, I have never encountered the problem of C++ standard features being broken by different C++ versions.
However, there have been cases of ABI breakage due to the migration from libstdc++
to libstdc++11
to comply with the C++11 standard.
Developers must understand that STL can also be added and deprecated by C++ versions, so the memory layout of STL objects can be changed and broken.
from spdlog.
Please make a release that corrects this problem.
Many depending ports might be affected.
from spdlog.
from spdlog.
Fixed in version 1.14.1
from spdlog.
In general, you need to make sure that at both build and consumption time, the user sees the same features.
If you still want to integrate this, I would recommend to introduce a define SPDLOG_USE_STRING_VIEW
and guard the availability of the functions with this define:
#if SPDLOG_USE_STRING_VIEW
#endif
In CMake you can then do something like
if () # tbd, check the active cxx standard
set(SPDLOG_USE_STRING_VIEW 1)
else()
set(SPDLOG_USE_STRING_VIEW 0)
endif()
target_compile_definition(spdlog PUBLIC SPDLOG_USE_STRING_VIEW=${SPDLOG_USE_STRING_VIEW})
from spdlog.
Related Issues (20)
- Logging messages within a custom sink causes a dead lock? HOT 1
- does SPDLOG consider control characters encountered when printing a character array as string termination markers? HOT 1
- Set a log zone prefix to default logger HOT 2
- Memory overflow warning in pattern_formatter-inl.h HOT 1
- Is there a plan to update the included libfmt to fix fmtlib/fmt#3540? HOT 8
- C++20 Modules "'std::basic_string': redefinition" HOT 2
- Make source_loc more resilient to invalid data HOT 3
- Show the lower digits of numeric fields, such as thread-id HOT 2
- spdlog::init_thread_pool caused a Segmentation fault HOT 4
- Auto generate tweakme.h HOT 17
- Can't create directory and file like "D:/Logs/log.txt" HOT 14
- Header-only version 1.14.0 complie with errors HOT 6
- vs编译工作正常, g++编译报错 HOT 5
- Async logging using MDC HOT 6
- Does the dist_sink support Factory pattern to create a new logger? HOT 3
- COMBINE "daily_file_sink" AND "rotating_file_sink" HOT 2
- How register work? HOT 3
- Does SPDLOG support conditional logging? HOT 6
- solution : "rotating_file_sink: failed renaming: permission denied " 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 spdlog.