Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

c++ - I can't seem to link g++ to my installed libcurl

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:UsersmatthAppDataLocalTempcceVTTmY.o:test.cpp:(.text+0xf): undefined reference to `_imp__curl_easy_init'
C:UsersmatthAppDataLocalTempcceVTTmY.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! :)

question from:https://stackoverflow.com/questions/65866244/i-cant-seem-to-link-g-to-my-installed-libcurl

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...