Skip to content

Compilation error - Undefined reference #352

@lucalazzaroni

Description

@lucalazzaroni

I installed the library using vcpkg and all went correctly.
I'd like to use Visual Studio Code as Editor, but when I build I receive this error:

C:\Users\luca\AppData\Local\Temp\cc74cy7b.o: In function cpr::Response cpr::Get<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&)': C:/vcpkg/installed/x64-windows/include/cpr/api.h:39: undefined reference to cpr::Session::Session()'
C:/vcpkg/installed/x64-windows/include/cpr/api.h:41: undefined reference to cpr::Session::Get()' C:/vcpkg/installed/x64-windows/include/cpr/api.h:39: undefined reference to cpr::Session::~Session()'
C:/vcpkg/installed/x64-windows/include/cpr/api.h:39: undefined reference to cpr::Session::~Session()' C:\Users\luca\AppData\Local\Temp\cc74cy7b.o: In function void cpr::priv::set_option<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >(cpr::Session&, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&&)':
C:/vcpkg/installed/x64-windows/include/cpr/api.h:25: undefined reference to `cpr::Session::SetOption(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'
collect2.exe: error: ld returned 1 exit status
The terminal process terminated with exit code: 1

I added these two lines in the tasks.json file to make it work but it seems that there's something that I'm missing:

"-I", "C:\\vcpkg\\installed\\x64-windows\\include", "-L", "C:\\vcpkg\\installed\\x64-windows\\lib -l cpr -l libcurl -l zlib"

The compiler I'm currently using is g++.
Thanks in advance for your help

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions