Search code examples
c++linuxubuntublitz++

How to install a C++ library (such as Blitz++) in a specific directory (in one that doesn't require sudo privileges), on Linux?


I tried looking at some links on this site. The closest I found to my problem was this one, but still I wasn't able to solve my problem with it

I'm kind of new at this but basically, I intend to install the Blitz++ library for C++, on Linux

Now, I've already done this once, by following the instructions of their GitHub repository, where the following commands install Blitz++ on a Unix-like system:

mkdir build      # Inside the cloned Github repo
cd build
cmake ..
make lib
sudo make install

The only thing I'm trying to do here is avoiding using sudo. As far as I can understand, that command installs files and the library itself inside directories that need sudo privileges accept any modifications (correct me if I'm wrong, I'm not well-versed here). But say if I want to install the library in I directory for which I have permissions, in order to avoid having to use sudo?

How can I install said library in the home directory for instance, on Linux, without having to invoke sudo?

I know that for other C++ libraries, there is a .configure file inside their respective directories, and by typing something along the lines of ./configure --prefix=<directory_path> (given that the current working directory is the library directory), it allows for the library to be installed in the specified path

But I can't for the life of me figure out how to do something similar with Blitz++, given that it has no .configure file whatsoever. Perhaps there is another way but I utterly lack knowledge in this area. Any help is appreciated.


Also, if anyone has any links or resources that help with understanding how C++ libraries work and how to generally install them, as well as any other recommended C++ resource, I'd appreciate if you let me know if it's not an inconvenience. Apologies for any mistakes and my ignorance


Solution

  • This is really a CMake question. Your looking for CMAKE_INSTALL_PREFIX. An example:

    mkdir build      # Inside the cloned Github repo
    cd build
    cmake -DCMAKE_INSTALL_PREFIX=<directory_path> ..
    make lib
    make install