I am new to programming in c++. I am trying to compile a code using curl in it. My visual studio code is able to find the file (as it autocompletes as well), but when I run "build task g++" it says the following:
C:\Users\matth\AppData\Local\Temp\cceVTTmY.o:test.cpp:(.text+0xf): undefined reference to `_imp__curl_easy_init'
C:\Users\matth\AppData\Local\Temp\cceVTTmY.o:test.cpp:(.text+0x21): undefined reference to `_imp__curl_easy_cleanup'
collect2.exe: error: ld returned 1 exit status
I don't get it. I installed curl with vcpkge and integrated it, so visual studio code can actually find it.
I used this in my args for tasks.json for g++:
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-I",
"C:\\Program Files\\vcpkg-master\\installed\\x86-windows\\include",
"-L",
"C:\\Program Files\\vcpkg-master\\installed\\x86-windows\\lib",
"-static"
],
I have also tried adding '-lcurl' but then the cmd actually responds saying 'cant't find lcurl'. I am struggling for a lot of hours now (as I said, new to c++) and I am getting really frustrated.
This is the code I am trying to compile:
#define CURL_STATICLIB
#include <curl/curl.h>
int main()
{
CURL *curl;
curl = curl_easy_init();
curl_easy_cleanup(curl);
return 0;
}
Anyone that knows how to fix this problem? All solutions I could find didn't work, so I decided to make my own account and try it this way...
Thanks a lot in advance, if you need more info, tell me! :)