mardi 10 mars 2020

Errors when use cURLpp in C++

When I use cURLpp to call an API, I got some errors, anyone can help me? I think caused by I linking both TorchScirpt library and cURLpp library because I can run another project with each library lonely.

Cmake file:

cmake_minimum_required(VERSION 3.15)
project(segment_api_C__)

set(CMAKE_CXX_STANDARD 11)

find_package(Torch REQUIRED)

add_executable(${PROJECT_NAME} main.cpp)

target_link_libraries(${PROJECT_NAME} ${TORCH_LIBRARIES} )
target_link_libraries(${PROJECT_NAME} -lcurlpp -lcurl -lm)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")

Error:

CMakeFiles/segment_api_C__.dir/main.cpp.o: In function `curlpp::internal::OptionContainer<std::list<std::string, std::allocator<std::string> > >::OptionContainer(std::list<std::string, std::allocator<std::string> > const&)':
/usr/include/curlpp/internal/OptionContainer.inl:38: undefined reference to `curlpp::internal::SList::SList(std::list<std::string, std::allocator<std::string> > const&)'
CMakeFiles/segment_api_C__.dir/main.cpp.o: In function `curlpp::internal::OptionContainer<std::list<std::string, std::allocator<std::string> > >::setValue(std::list<std::string, std::allocator<std::string> > const&)':
/usr/include/curlpp/internal/OptionContainer.inl:52: undefined reference to `curlpp::internal::SList::operator=(std::list<std::string, std::allocator<std::string> > const&)'
CMakeFiles/segment_api_C__.dir/main.cpp.o: In function `curlpp::internal::OptionContainer<std::list<std::string, std::allocator<std::string> > >::getValue()':
/usr/include/curlpp/internal/OptionContainer.inl:59: undefined reference to `curlpp::internal::SList::operator std::list<std::string, std::allocator<std::string> >()'
collect2: error: ld returned 1 exit status
CMakeFiles/segment_api_C__.dir/build.make:86: recipe for target 'segment_api_C__' failed
make[3]: *** [segment_api_C__] Error 1
CMakeFiles/Makefile2:75: recipe for target 'CMakeFiles/segment_api_C__.dir/all' failed
make[2]: *** [CMakeFiles/segment_api_C__.dir/all] Error 2
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/segment_api_C__.dir/rule' failed
make[1]: *** [CMakeFiles/segment_api_C__.dir/rule] Error 2
Makefile:118: recipe for target 'segment_api_C__' failed
make: *** [segment_api_C__] Error 2

Thank for your help and have a nice day.

Aucun commentaire:

Enregistrer un commentaire