Install dereko2vec and vecs2mmap
There were no install rules at all, so "make install" stopped with "No rule to
make target 'install'", although the README has been telling people to run it.
Only the two programs that are useful outside of a build directory are
installed. The others keep the generic names they inherited from word2vec, like
distance or kmeans_txt, which have no business in a directory on everybody's
PATH.
The README asked for collocatordb 1.3.0 and ctest3; it now names the rocksdb
package of the distribution, collocatordb 1.5.0, which builds against it, and
says that the build directory has to be build/ inside the sources, because the
test looks for the binary relative to it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Change-Id: I8637f7faa0b8061e7e016637f5348bc26c9e3529
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f6faee7..e9c5d2b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,22 +14,34 @@
include_directories(/usr/local/include;/usr/local/kl/include)
link_directories(/usr/local/kl/lib;/usr/local/lib;/usr/local/lib64)
-find_library(COLLOCATORDB libcollocatordb_static.a REQUIRED)
-if (NOT COLLOCATORDB)
- message(FATAL_ERROR "No libcollocatordb_static.a found. Please install from https://korap.ids-mannheim.de/gerrit/plugins/gitiles/private/collocatordb")
+# A static dereko2vec needs everything as a static library. An ordinary build
+# takes the shared ones, and it has to take them explicitly: a leftover static
+# library below /usr/local would otherwise win over the shared library of the
+# distribution, because cmake weighs the search path higher than the suffix.
+# Set -DCOLLOCATORDB=<path> or -DROCKSDB=<path> to pick specific ones.
+if (STATIC_DEREKO2VEC)
+ find_library(COLLOCATORDB libcollocatordb_static.a)
+ find_library(ROCKSDB librocksdb.a)
+else ()
+ set(_dereko2vec_lib_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".so")
+ find_library(COLLOCATORDB NAMES collocatordb)
+ find_library(ROCKSDB NAMES rocksdb)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${_dereko2vec_lib_suffixes})
endif ()
-# No version pin, so that the rocksdb of the distribution can be used. A static
-# build needs the static library, otherwise a shared one will do as well.
-if (STATIC_DEREKO2VEC)
- find_library(ROCKSDB librocksdb.a REQUIRED)
-else ()
- find_library(ROCKSDB NAMES rocksdb REQUIRED)
+if (NOT COLLOCATORDB)
+ message(FATAL_ERROR "No collocatordb found. Please install it from "
+ "https://korap.ids-mannheim.de/gerrit/plugins/gitiles/ids-kl/collocatordb"
+ " - a static dereko2vec needs libcollocatordb_static.a, otherwise "
+ "libcollocatordb.so is enough.")
endif ()
if (NOT ROCKSDB)
- message(FATAL_ERROR "No rocksdb found. Install the rocksdb development package of your distribution, e.g. librocksdb-dev or rocksdb-devel.")
+ message(FATAL_ERROR "No rocksdb found. Install the rocksdb development "
+ "package of your distribution, e.g. librocksdb-dev or rocksdb-devel.")
endif ()
-message(STATUS "Using RocksDB library ${ROCKSDB}")
+message(STATUS "Using collocatordb ${COLLOCATORDB}")
+message(STATUS "Using RocksDB ${ROCKSDB}")
file(GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/src/*.c)
foreach (mysourcefile ${APP_SOURCES})
@@ -48,6 +60,12 @@
endif ()
endforeach (mysourcefile ${APP_SOURCES})
+# Only the two that are used outside of a build directory: the trainer and the
+# converter that writes the memory mappable form derekovecs maps. The remaining
+# programs keep the generic names they inherited from word2vec, like distance
+# or kmeans_txt, which have no business in a directory on everybody's PATH.
+install(TARGETS dereko2vec vecs2mmap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+
enable_testing()
find_program(BASH_PROGRAM bash)
if (BASH_PROGRAM)
diff --git a/README.md b/README.md
index 5fef2fe..2b74d26 100644
--- a/README.md
+++ b/README.md
@@ -6,8 +6,11 @@
### Dependencies
-* cmake3
-* [libcollocaltordb](https://korap.ids-mannheim.de/gerrit/plugins/gitiles/ids-kl/collocatordb) >= v1.3.0
+* cmake
+* the rocksdb of the distribution, e.g. `librocksdb-dev` on Debian and Ubuntu
+ or `rocksdb-devel` on Fedora and Rocky Linux
+* [libcollocatordb](https://korap.ids-mannheim.de/gerrit/plugins/gitiles/ids-kl/collocatordb) >= v1.5.0,
+ which builds against that rocksdb
### Build and install
@@ -16,9 +19,24 @@
mkdir build
cd build
cmake ..
-make && ctest3 --extra-verbose && sudo make install
+make && ctest --extra-verbose && sudo make install
```
+This installs `dereko2vec` and `vecs2mmap`. The build directory has to be
+`build` inside the sources, the test looks for the binary relative to it.
+
+A completely static `dereko2vec` is about 10% faster on the collocator database
+and needs a static rocksdb and a static collocatordb:
+
+```bash
+cmake -DSTATIC_DEREKO2VEC=ON ..
+```
+
+Debian and Ubuntu ship `librocksdb.a` in `librocksdb-dev`. Fedora, Rocky Linux
+and RHEL do not, the
+[collocatordb README](https://korap.ids-mannheim.de/gerrit/plugins/gitiles/ids-kl/collocatordb)
+says how to build one there without shadowing the headers of the package.
+
## Run
The command to build word embeddings is exactly the same as in the original version, except that we added type 5 for setting up a purely count based collocation database.