Fix installation on CentOS 7
Change-Id: I673e89d567a23376655320ce9edce0fefc0f2d8c
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 684754c..322df37 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,23 +1,24 @@
cmake_minimum_required(VERSION 3.9)
project(collocatordb VERSION 1.2.0 DESCRIPTION "Storing and retrieving collocation counts based on RocksDB")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fno-rtti")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fno-rtti -std=c++11 -std=gnu++11")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
include(GNUInstallDirs)
-include_directories(/usr/local/include)
-find_library(ROCKSDB librocksdb.so.5.11)
+include_directories(/usr/local/include;/usr/local/kl/include)
+link_directories(/usr/local/lib;/usr/local/kl/lib)
+find_library(ROCKSDB NAMES librocksdb.so.5.11 librocksdb.so.5.10 librocksdb.so.5)
find_library(ROCKSDB_STATIC librocksdb.a)
enable_testing()
add_library(collocatordb SHARED src/collocatordb.cc)
-target_link_libraries(collocatordb pthread rt snappy z bz2 lz4 zstd ${ROCKSDB})
+target_link_libraries(collocatordb pthread rt snappy z bz2 lz4 zstd ${ROCKSDB} dl)
set_target_properties(collocatordb PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 1
PUBLIC_HEADER src/collocatordb.h)
add_library(collocatordb_static STATIC src/collocatordb.cc)
-target_link_libraries(collocatordb_static ${ROCKSDB_STATIC} pthread rt snappy z bz2 lz4 zstd)
+target_link_libraries(collocatordb_static ${ROCKSDB_STATIC} pthread rt snappy z bz2 lz4 zstd dl)
add_executable(basic_test tests/basic_test.c tests/acutest.h)
TARGET_LINK_LIBRARIES(basic_test ${ROCKSDB} collocatordb)
diff --git a/README.md b/README.md
index 09edb37..4e9e5b1 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
### Install RocksdDB and prerequisites
* install prerequisites on CentOS, FeDora, RHEL
```
- sudo yum install cmake snappy snappy-devel zlib zlib-devel bzip2 bzip2-devel lz4-devel libzstd-devel libomp-devel
+ sudo yum install cmake3 snappy snappy-devel zlib zlib-devel bzip2 bzip2-devel lz4-devel libzstd-devel libomp-devel
git clone https://github.com/gflags/gflags.git
cd gflags
@@ -16,7 +16,7 @@
```
sudo apt-get install cmake libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev libomp-dev
```
-* install RocksDBn [v5.11.3](https://github.com/facebook/rocksdb/releases/tag/v5.11.3)
+* install [RocksDB v5.11.3](https://github.com/facebook/rocksdb/releases/tag/v5.11.3)
```
git clone https://github.com/facebook/rocksdb.git
cd rocksdb
@@ -30,8 +30,8 @@
cd collocatordb
mkdir -p build
cd build
-cmake ..
-make && make test && sudo make install
+cmake3 ..
+make && ctest3 --extra-verbose && sudo make install
```
## Provided API
```
diff --git a/tests/basic_test.c b/tests/basic_test.c
index 8872c48..56d9905 100644
--- a/tests/basic_test.c
+++ b/tests/basic_test.c
@@ -78,8 +78,7 @@
void test_writing() {
char *tmp = tempnam(NULL, NULL);
long size = 0;
-
- printf("%s\n", acutest_argv0_);
+ int i;
char *rocksdbfn = malloc(strlen(tmp)+strlen(".rocksdb"));
strcpy (rocksdbfn, tmp);
@@ -96,7 +95,7 @@
fclose(h);
read_vocab(cdb, vocabfn);
inc_collocator(cdb, 0, 1, 4); size++;
- for (int i=0; i < 1000; i++) {
+ for (i=0; i < 1000; i++) {
inc_collocator(cdb, 0, 1, i % 5); size++;
inc_collocator(cdb, 0, 1, -i % 5); size++;
inc_collocator(cdb, 1, 0, i % 5); size++;