ipkn / crow

Crow is very fast and easy to use C++ micro web framework (inspired by Python Flask)
BSD 3-Clause "New" or "Revised" License
7.46k stars 889 forks source link

got some error when run crow #363

Open baopanda opened 4 years ago

baopanda commented 4 years ago

Hi everyone, I have tried to run some examples of code using crow but I faced a problem so I need your help.

my code

#include "crow_all.h"

int main()
{
    crow::SimpleApp app;

    CROW_ROUTE(app, "/")([](){
        return "Hello world";
    });

    app.port(18080).multithreaded().run();
}

CMakelist.txt

cmake_minimum_required(VERSION 3.15)
project(untitled)

set(CMAKE_CXX_STANDARD 11)

add_executable(untitled main.cpp)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -lboost_system")

Error:

CMakeFiles/untitled.dir/main.cpp.o: In function `__static_initialization_and_destruction_0(int, int)':
/usr/include/boost/system/error_code.hpp:206: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:208: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:210: undefined reference to `boost::system::system_category()'
CMakeFiles/untitled.dir/main.cpp.o: In function `boost::system::error_code::error_code()':
/usr/include/boost/system/error_code.hpp:439: undefined reference to `boost::system::system_category()'
CMakeFiles/untitled.dir/main.cpp.o: In function `boost::system::error_category::std_category::equivalent(int, std::error_condition const&) const':
/usr/include/boost/system/error_code.hpp:656: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:659: undefined reference to `boost::system::generic_category()'
CMakeFiles/untitled.dir/main.cpp.o: In function `boost::system::error_category::std_category::equivalent(std::error_code const&, int) const':
/usr/include/boost/system/error_code.hpp:686: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:689: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:701: undefined reference to `boost::system::generic_category()'
CMakeFiles/untitled.dir/main.cpp.o: In function `boost::asio::error::get_system_category()':
/usr/include/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
mrozigor commented 4 years ago

Did you installed boost in your system?

baopanda commented 4 years ago

Did you installed boost in your system?

@mrozigor yeppp, i have installed boost. Do you have any ideas to fix it?

mrozigor commented 4 years ago

Maybe try to use find_package( Boost 1.52 COMPONENTS system thread REQUIRED ) in your CMakeLists.txt file as in project's CMakeLists.txt file?

baopanda commented 4 years ago

Maybe try to use find_package( Boost 1.52 COMPONENTS system thread REQUIRED ) in your CMakeLists.txt file as in project's CMakeLists.txt file?

I hve tried and it cannot find COMPONENTS system thread REQUIRED!

mrozigor commented 4 years ago

So it means that you don't have installed boost-1.52. Can you give me some output from your package manager with boost version?

baopanda commented 4 years ago

@mrozigor It said "Could NOT find Boost (missing: filesystem)", Can you help me to solve that problem?

mrozigor commented 4 years ago

It looks like problem with boost installation. Or maybe path to library isn't set. Try to find the solution through goole.

shitijkarsolia commented 4 years ago

I'm facing the same issue but this command "find_package( Boost 1.52 COMPONENTS system thread REQUIRED )" was successfully able to find boost. How do I successfully run the entire code?

mrozigor commented 4 years ago

Maybe try https://stackoverflow.com/a/27696770 ?