Can't use restclient-cpp
baopanda opened this issue · 2 comments
baopanda commented
Hi sir, I have include your restclient.h file #include "restclient-cpp/include/restclient-cpp/restclient.h" and get an error, can you help me to solve this? I am using linux OS
Thanks u
code:
#include "restclient-cpp/include/restclient-cpp/restclient.h"
int main(int, char **){
RestClient::Response r = RestClient::post("http://127.0.0.1:8880/nlp/tone", "application/json", "{\\\"sentence\\\":\\\"Hà Đức Chinh tỏa sáng với hat-trick vào lưới Brunei và khiến HLV Park Hang Seo 2 lần trong phòng họp báo sửng sốt.\\\"}");
}
Error:
CMakeFiles/untitled5.dir/main.cpp.o: In function `main':
/home/bao/CLionProjects/untitled5/main.cpp:5: undefined reference to `RestClient::post(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
CMakeFiles/untitled5.dir/build.make:83: recipe for target 'untitled5' failed
make[3]: *** [untitled5] Error 1
CMakeFiles/Makefile2:75: recipe for target 'CMakeFiles/untitled5.dir/all' failed
make[2]: *** [CMakeFiles/untitled5.dir/all] Error 2
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/untitled5.dir/rule' failed
make[1]: *** [CMakeFiles/untitled5.dir/rule] Error 2
Makefile:118: recipe for target 'untitled5' failed
make: *** [untitled5] Error 2
Cmakefile:
cmake_minimum_required(VERSION 3.15)
project(untitled5)
add_executable(untitled5 main.cpp)
set(CMAKE_CXX_STANDARD 11)
et-nik commented
You must add rustclient and curl dependencies:
cmake_minimum_required(VERSION 3.15)
project(untitled5)
find_package(CURL REQUIRED)
add_executable(untitled5 main.cpp restclient-cpp/source/restclient.cc restclient-cpp/source/connection.cc restclient-cpp/source/helpers.cc)
target_link_libraries (untitled5 ${CURL_LIBRARIES})
set(CMAKE_CXX_STANDARD 11)
baopanda commented
@et-nik It works, thanks for your help my friend, wish u have a nice day!
You must add rustclient and curl dependencies:
cmake_minimum_required(VERSION 3.15) project(untitled5) find_package(CURL REQUIRED) add_executable(untitled5 main.cpp restclient-cpp/source/restclient.cc restclient-cpp/source/connection.cc restclient-cpp/source/helpers.cc) target_link_libraries (untitled5 ${CURL_LIBRARIES}) set(CMAKE_CXX_STANDARD 11)