Undefined reference errors when trying to use qspdlog in a .pro qt project
- Dominant language
- C++
- Stars
- 72
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
First of, thanks for your time and effort!
I am trying to use the qspdlog in a qt project which uses qmake to build (instead of cmake). I am getting `undefined reference errors` to some of the types in the `spdlog` library when building the project. I believe I am doing all the right things but this could simply be a cmake/qmake or a library flag issue which I am failing to root cause. I have already spent a good time debugging and trying various things (like building with different versions of C++ in case this is a ABI issue) with no avail. I would appreciate any tip/help/example you can provide to resolve this. Thanks!
Here is a simple code that's failing to build:
```
#include "main_window.hh"
#include
#include "qspdlog/qspdlog.hpp"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
QSpdLog log;
return a.exec();
}
```
And here is how qspdlog is added to the `.pro` file:
```
INCLUDEPATH += /path/to/the/qspdlog/include
LIBS += -L/path/to/the/qspdlog -lqspdlog_lib
```
I am using C++17 for building all the libraries (spdlog, qspdlog, and my project).
Note that I am able to build and run the sample code in qspdlog with no problem.
Here are some of the `undefined reference` errors I get:
```
qspdlog\build\src/libqspdlog_lib.a(qspdlog.cpp.obj):qspdlog.cpp:(.text+0x10af): undefined reference to `spdlog::sinks::base_sink::base_sink()'
qspdlog\build\src/libqspdlog_lib.a(qspdlog.cpp.obj):qspdlog.cpp:(.rdata$_ZTVN6spdlog5sinks9base_sinkISt5mutexEE[_ZTVN6spdlog5sinks9base_sinkISt5mutexEE]+0x20): undefined reference to `spdlog::sinks::base_sink::log(spdlog::details::log_msg const&)'
qspdlog\build\src/libqspdlog_lib.a(qspdlog.cpp.obj):qspdlog.cpp:(.rdata$_ZTVN6spdlog5sinks9base_sinkISt5mutexEE[_ZTVN6spdlog5sinks9base_sinkISt5mutexEE]+0x28): undefined reference to `spdlog::sinks::base_sink::flush()'
qspdlog\build\src/libqspdlog_lib.a(qspdlog.cpp.obj):qspdlog.cpp:(.rdata$_ZTVN6spdlog5sinks9base_sinkISt5mutexEE[_ZTVN6spdlog5sinks9base_sinkISt5mutexEE]+0x30): undefined reference to `spdlog::sinks::base_sink::set_pattern(std::__cxx11::basic_string, std::allocator > const&)'
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the qmake .pro configuration and compare its INCLUDEPATH and LIBS entries with the working qspdlog sample build. Trace which spdlog dependencies are linked and verify the example project builds with the same C++17 setup; done means the provided Qt application links and runs without undefined references.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100