I am trying to use an open-source library into my project, specifically this one here.
I have followed the installation guidelines and installed it globally with
sudo cmake --build "build" --config Release --target install
And I could see that the library is installed in /usr/local/lib
, now back to my own C++ code, when I tried to
#include <benchmark/benchmark.h>
as shown in the instruction still no go with error
'benchmark/benchmark.h' file not found
SO is there any step that is missing?
In /usr/local/lib
I have:
libbenchmark.a
libbenchmark_main.a
And in /usr/local/include
I have:
benchmark
I am not using CMake for my XCode project.
————– Segmentation ————
After digging on the question here.
I added this /usr/local/include
into the Header Search Paths
as following.
And then I tried
#include "benchmark/benchmark.h" // I tried <benchmark/benchmark.h> as well
But this resulted in a direct build failure with error
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
2
Answers
Thanks for the many helps, I have finally figured it out.
Go to
build settings
in Xcode and add both header and library search pathAnd then go to
linking
, add linkers, for my case it looks like thisAssuming your project uses
cmake
too, yourCMakeLists.txt
should contain something like this:This should resolve problems with include and linking issues (you didn’t specified actual nature of your problem).