google / leveldb

LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.
BSD 3-Clause "New" or "Revised" License
35.71k stars 7.72k forks source link

Cna not build Leveldb1.23 #1161

Open maths644311798 opened 6 months ago

maths644311798 commented 6 months ago

I follow README.md. System: Ubuntu 22.04.3 LTS. After cmake --build ., it shows

[ 41%] Linking CXX executable c_test
/usr/bin/ld: CMakeFiles/c_test.dir/db/c_test.c.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/c_test.dir/build.make:117: c_test] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:290: CMakeFiles/c_test.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
maths644311798 commented 6 months ago

It seems that adding SET(CMAKE_EXE_LINKER_FLAGS " -no-pie") in the CMakeLists.txt works.