Home > Mobile >  Can't compile a Crow sample - boost/optional.hpp: No such file or directory
Can't compile a Crow sample - boost/optional.hpp: No such file or directory

Time:04-25

I'd like to compile and test Crow C microframework in Debian Linux 11:

  1. Download the latest crow.deb, currently crow-v1.0 1.deb.

  2. Install it:

    $ sudo dpkg -i crow-v1.0 1.deb
    Selecting previously unselected package crow.
    (Reading database ... 587955 files and directories currently installed.)
    Preparing to unpack crow-v1.0 1.deb ...
    Unpacking crow (1.0 1) ...
    Setting up crow (1.0 1) ...
    
  3. Create a .cpp file with a sample code from crowcpp.org:

    $ echo '#include "crow.h"
    
    int main()
    {
        crow::SimpleApp app;
    
        CROW_ROUTE(app, "/")([](){
            return "Hello world";
        });
    
        app.port(18080).run();
    }' > crowtest.cpp
    
  4. Try to compile it:

    $ g   crowtest.cpp -lpthread
     In file included from /usr/include/crow.h:2,
                      from crowtest.cpp:1:
     /usr/include/crow/query_string.h:9:10: fatal error: boost/optional.hpp: No such file or directory
         9 | #include <boost/optional.hpp>
           |          ^~~~~~~~~~~~~~~~~~~~
     compilation terminated.
    
  5. See the error above. How can I compile the Crow sample code?

CodePudding user response:

You need to install Boost, for Debian that would be apt install libboost-dev.

  • Related