我正在尝试在我的项目中使用 spdlog。根据 spdlog docu,我只需要复制包含文件夹下的文件并使用 C++ 11 编译器。
我将 /include/spdlog 文件夹复制到我的项目根文件夹,但在尝试构建项目后出现了很多错误。有些是ff:
/home/project/Documents/project-server/spdlog/spdlog.h:46:39: error: variable or field ‘set_error_handler’ declared void
void set_error_handler(log_err_handler);
^
/home/project/Documents/project-server/spdlog/spdlog.h:46:24: error: ‘log_err_handler’ was not declared in this scope
void set_error_handler(log_err_handler);
^
In file included from /home/project/Documents/project-server/main.cpp:13:0:
/home/project/Documents/project-server/spdlog/spdlog.h:74:79: error: ‘filename_t’ does not name a type
std::shared_ptr<logger> basic_logger_mt(const std::string& logger_name, const filename_t& filename, bool truncate = false);
^
/home/project/Documents/project-server/spdlog/spdlog.h:75:79: error: ‘filename_t’ does not name a type
std::shared_ptr<logger> basic_logger_st(const std::string& logger_name, const filename_t& filename, bool truncate = false);
^
/home/project/Documents/project-server/spdlog/spdlog.h:80:82: error: ‘filename_t’ does not name a type
std::shared_ptr<logger> rotating_logger_mt(const std::string& logger_name, const filename_t& filename, size_t max_file_size, size_t max_files);
我尝试在 CMakeLists.txt 中添加以下内容
target_include_directories(ProjectName INTERFACE spdlog)
include_directories(spdlog)
target_link_libraries(ProjectName .... -libspdlog-dev)
(我安装了 libspdlog-dev)
add_subdirectory(spdlog)
但以上都不起作用。有谁知道我该如何解决这个问题?非常感谢!