我是新来c++的,请不要太苛刻。我正在尝试在C++程序中使用spdlog,并使用Jetbrains中的CLion。
这是我的截图,但不知道我做错了什么。请告诉我哪里做错了。
这是我的main.cpp
#include <iostream>
#include "include/spdlog/spdlog.h"
int main() {
std::cout << "Hello, World!" << std::endl;
spdlog::info("hello world");
return 0;
}这是我的CMakeList.txt
cmake_minimum_required(VERSION 3.17) project(Lesson01)
set(CMAKE_CXX_STANDARD 14)
add_executable(Lesson01 main.cpp) include_directories(spdlog)

谢谢
发布于 2020-08-21 20:39:17
在您创建的原型中,您已经提到了两次关键字,第一次是在#之后,第二次是在引号之间。
我一直在互联网上寻找和spdlog原型的基本写作是刚刚。这里的链接是:https://github.com/gabime/spdlog
#包含"spdlog/spdlog.h“
测试没有在你的代码中包含第二个。
万事如意
马修
发布于 2020-08-21 21:11:10
在您的代码中有#include "include/spdlog/spdlog.h",根据您链接的屏幕截图,可以找到这个include。然而,它随后抱怨spdlog.h尝试#include <spdlog/common.h>,但找不到此文件。
总而言之,这听起来像是您没有为库设置正确的include目录,而只是通过过度指定路径来获得正确的第一个文件。
我会尝试将include_directories(spdlog)更改为include_directories(include) (或者可能是include_directories(include/spdlog),不完全确定哪个文件夹是库所在的基本文件夹)。如果你愿意,你也可以添加所有这些;我不认为在这里添加太多会破坏任何东西,但它可能会影响编译速度,所以尽量只保留正确的。
此外,在进行此更改后,您可能需要将原始的include从#include "include/spdlog/spdlog.h"更改为#include "spdlog/spdlog.h"。
https://stackoverflow.com/questions/63522863
复制相似问题