Repository metrics
- Stars
- (7,968 stars)
- PR merge metrics
- (平均マージ 4d 2h) (30d で 19 merged PRs)
説明
Awright?
I installed Google Bench globally on a Linux based system using:
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON
sudo make install
However, when I attempted to build an example benchmark, i.e. the Basic usage one, my build failed. The relevant cmake script looks like this:
add_executable(basic_bench basic_bench.cpp)
target_link_libraries(basic_bench
pthread
benchmark)
/usr/bin/ld: //usr/local/lib/libbenchmark.a(benchmark.cc.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
Being one to put a lot of stock by the everyday heros that are of compiler error messages, I inelegantly papped the following line at the top of the benchmark library CMake script, and rebuilt:
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
And lo and behold, the example then worked!
I haven't actually encountered PIC before on my travels, but some Wikipedia level research suggests that it is maybe what one would want to have when dealing with an externally linked library. Perhaps someone more well versed in the area would know what's going on?
Making this issue as information for folk that have the same problem (since I couldn't find a previous example).
Should I make a pull request to add this to the build script, or perhaps in troubleshooting?