【发布时间】:2021-02-09 13:57:40
【问题描述】:
我正在尝试在我的项目中使用一个开源库,特别是这个here。
我已遵循安装指南并在全球范围内使用
sudo cmake --build "build" --config Release --target install
我可以看到库安装在/usr/local/lib,现在回到我自己的C++代码,当我尝试时
#include <benchmark/benchmark.h>
如指令所示仍然没有出错
'benchmark/benchmark.h' file not found
所以有没有遗漏的步骤?
在/usr/local/lib 我有:
libbenchmark.a
libbenchmark_main.a
在/usr/local/include 我有:
benchmark
我没有在我的 XCode 项目中使用 CMake。
-------------- 分割------------
深挖问题here.
我将此/usr/local/include 添加到Header Search Paths 中,如下所示。
然后我尝试了
#include "benchmark/benchmark.h" // I tried <benchmark/benchmark.h> as well
但这导致直接构建失败并出现错误
Undefined symbols for architecture x86_64:
"benchmark::internal::InitializeStreams()", referenced from:
___cxx_global_var_init in main.o
ld: symbol(s) not found for architecture x86_64
【问题讨论】:
-
我假设它把标题放在
/usr/local/include中,而你的编译器包含目录中没有该路径。 -
@drescherjm 是的,在文件夹里面我有文件夹
benmark,我怎样才能包含它? -
这将是您需要在 XCode 中更改的一些设置。我不使用那个 IDE,所以我不能告诉你设置是什么。
-
这是一个关于如何在 XCode 中添加包含路径的老问题:https://stackoverflow.com/questions/14134064/how-to-set-include-path-in-xcode-project