primecount icon indicating copy to clipboard operation
primecount copied to clipboard

describing how to build dynamically linked (lib)primecount without root

Open dimpase opened this issue 4 years ago • 6 comments

Playing with cmake a bit, I found how to set up libprimecount and primecount without root, something that's valuable in a number of settings, e.g. on HPC clusters, other shared machines - or building libprimecount extensions (e.g. Python ones). Should this be added to docs?

The following is only tested on Linux so far.

  1. set the desired location, e.g. export WDIR=$HOME/tmp
  2. install libprimesieve as follows:
cd primesieve
cmake -DBUILD_STATIC_LIBS=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$WDIR .
make -j  install     # no sudo!
  1. install primecount as follows
cd primecount
cmake -DBUILD_STATIC_LIBS=OFF -DBUILD_SHARED_LIBS=ON \
       -DCMAKE_INSTALL_PREFIX=$WDIR \
      -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE  -DCMAKE_INSTALL_RPATH=$WDIR \
      -DCMAKE_SKIP_BUILD_RPATH=FALSE  -DBUILD_LIBPRIMESIEVE=OFF  \
      -DCMAKE_FIND_ROOT_PATH=$WDIR/lib/cmake  \
      -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY .
make -j install # no sudo!
  1. done, now you can do $WDIR/bin/primecount 1000000 and it will work as it should.

dimpase avatar Nov 21 '21 23:11 dimpase

this works on macOS too.

dimpase avatar Nov 22 '21 00:11 dimpase

Should this be added to docs?

Personally I feel like the documentation should not contain too many expert topics. My documentation is currently written so that beginners and intermediate devs can get started quickly. Expert devs that are e.g. packaging software (or writing bindings) usually know exactly what build settings to use in their particular environment. Even if this piece of information is missing in the documentation experts will likely be able to figure it out quickly by themselves.

kimwalisch avatar Nov 23 '21 11:11 kimwalisch

I personally spent many hours figuring this out, and I have been packaging software for 20+ years. cmake docs don't provide ready to use instructions of this sort, and their docs are lacking in general (e.g. try to find info on ldconfig there) - aimed at the users with root access, often, and totally avoiding the situation I describe here.

There are no instructions of this sort found on stackoverflow, I looked hard there. Let's ask a cmake expert, whether this is easy to figure out ? @isuruf ?

dimpase avatar Nov 23 '21 14:11 dimpase

beginners and intermediate devs can get started quickly

No, if you are a primecount beginner wanting to run it without a root access, e.g. a student with access to a shared Unix server, your current docs are not helping, they always have sudo in them. Or assuming one only has an office Linux desktop, centrally managed, thus, no root (that's the case where I work, for instance).

dimpase avatar Nov 23 '21 14:11 dimpase

I'm not sure I understand what the issue is.

isuruf avatar Nov 24 '21 06:11 isuruf

@isuruf - the question is whether it is well-documented elsewhere how to correctly install dynamic libs and executables built with cmake if the user does not have root.

I propose to add such details to the docs here, as it appears tricky. IMHO the standard cmake docs assume that on Linux one installs into /usr/local, using sudo.

dimpase avatar Nov 24 '21 08:11 dimpase