Compiling my first c++ program with stxxl

  • Isaac Perez
    Isaac Perez


    How I said in my previous post, I just installed the STXXL library on my computer. I use ArchLinux and I install the STXXL library from AUR (Arch Users Repository) using yaourt.

    Now I want compile and running my very first sample program (in this case examples/something/phonebills.cpp). About this are my questions:

    (1) Is posible compile a C++ program with stxxl library without a automatic building tool like CMake or othres?.. i.e handwriting in the terminal like a standard c++ program

    In the case of a positive answer for previous question:

    (2) How do I compile a c++ program with stxxl library?, What libraries should I link to my program when I am compiling it?... what I have to type in the terminal?

    Thanks in advance for any help and/or suggestions.

  • Timo Bingmann
    Timo Bingmann

    Yes this is of course possible, though usually I use one of the build methods described in the documentation.

    I cant give you an exact line, but basically you need three things:
    - an include path to the stxxl headers, unless already in /usr/include/stxxl
    - link with libstxxl.a
    - link with the few libraries stxxl uses, I think that is only pthread and openMP, unless you compiled with boost (unnecessary).

  • Isaac Perez
    Isaac Perez

    Greetings and thanks for responding.

    As I said before I use ArchLinux and I installed stxxl using yaourt from AUR. Why repeat it?... Researching and reviewing my stxxl installation, I got to know that the installation generates a .so file (that is, a dynamically linked library) and no a .a file (static library).

    Because of this, the CMake file given in (in the section where stxxl is installed as a library), generates the following error:

    CMake Error at / usr/lib64/cmake/stxxl/stxxl-targets.cmake: 76 (message):
       The imported target "stxxl_static" references the file

    "/ usr / lib / libstxxl.a"

    but this file does not exist. Possible Reasons include:

    * The file was deleted, renamed, or moved to another location.

    * An install or uninstall procedure did not complete successfully.

    * The installation package was faulty and Contained

    "/ usr/lib64/cmake/stxxl/stxxl-targets.cmake"

    but not all the files it references.

    The above is only an excerpt, I just copy the output of CMake interest for the problem that I have. The error is because the .a file not exist.

    The question here is then:
    How to modify the given CMake file to work with the .so file?

    Thanks again for any responses and/or suggestions.