-1

我在项目中包含并使用 libcurl,但出现此错误

unable to generate p/invoke for "function_declaration" decorated_name; calling convention missing in metadata

和别的。我用 Visual Studio C++ 编码我搜索了那些,我读到这个库可能有问题,它是从 C 文件编译的。我的项目在 c++/cli 中。你认为这是问题所在吗?我能做什么?

#include <curl/curl.h>
#include <curl/easy.h>

这包括我正在使用的

那是代码

static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{
    int written = fwrite(ptr, size, nmemb, (FILE *)stream);
    return written;
}

int main()     
{
    CURL *curl_handle;
    static const char *headerfilename = "head.out";
    FILE *headerfile;
    static const char *bodyfilename = "body.html";
    FILE *bodyfile;
    curl_global_init(CURL_GLOBAL_ALL);
    curl_handle = curl_easy_init();
    curl_easy_setopt(curl_handle, CURLOPT_URL, "http://url");
    curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
    curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
    curl_easy_setopt(curl_handle,   CURLOPT_WRITEHEADER, headerfile);
    curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, bodyfile);
    curl_easy_perform(curl_handle);
    fclose(headerfile);
    fclose(bodyfile);
}

链接错误 LNK2031

链接错误 LNK2019

  : error LNK2031: p/invoke konnte nicht für ""extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ)" generiert werden. In den Metadaten fehlt die Aufrufkonvention.
   : error LNK2031: p/invoke konnte nicht für ""extern "C" enum CURLFORMcode __clrcall curl_formadd(struct curl_httppost * *,struct curl_httppost * *,...)" (?curl_formadd@@$$J0YM?AW4CURLFORMcode@@PAPAUcurl_httppost@@0ZZ)" generiert werden. In den Metadaten fehlt die Aufrufkonvention.
   : error LNK2031: p/invoke konnte nicht für ""extern "C" struct curl_slist * __clrcall curl_slist_append(struct curl_slist *,char const *)" (?curl_slist_append@@$$J0YMPAUcurl_slist@@PAU1@PBD@Z)" generiert werden. In den Metadaten fehlt die Aufrufkonvention.
   : error LNK2031: p/invoke konnte nicht für ""extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" (?curl_easy_perform@@$$J0YM?AW4CURLcode@@PAX@Z)" generiert werden. In den Metadaten fehlt die Aufrufkonvention.
  : error LNK2031: p/invoke konnte nicht für ""extern "C" void __clrcall curl_easy_cleanup(void *)" (?curl_easy_cleanup@@$$J0YMXPAX@Z)" generiert werden. In den Metadaten fehlt die Aufrufkonvention.
  : error LNK2031: p/invoke konnte nicht für ""extern "C" void * __clrcall curl_easy_init(void)" (?curl_easy_init@@$$J0YMPAXXZ)" generiert werden. In den Metadaten fehlt die Aufrufkonvention.
  : error LNK2031: p/invoke konnte nicht für ""extern "C" enum CURLcode __clrcall curl_global_init(long)" (?curl_global_init@@$$J0YM?AW4CURLcode@@J@Z)" generiert werden. In den Metadaten fehlt die Aufrufkonvention.
  : error LNK2020: Nicht aufgelöstes Token (0A000016) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ).
   : error LNK2020: Nicht aufgelöstes Token (0A00001A) "extern "C" enum CURLFORMcode __clrcall curl_formadd(struct curl_httppost * *,struct curl_httppost * *,...)" (?curl_formadd@@$$J0YM?AW4CURLFORMcode@@PAPAUcurl_httppost@@0ZZ).
   : error LNK2020: Nicht aufgelöstes Token (0A00001B) "extern "C" enum CURLFORMcode __clrcall curl_formadd(struct curl_httppost * *,struct curl_httppost * *,...)" (?curl_formadd@@$$J0YM?AW4CURLFORMcode@@PAPAUcurl_httppost@@0ZZ).
   : error LNK2020: Nicht aufgelöstes Token (0A000020) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ).
   : error LNK2028: Nicht aufgelöstes Token (0A000021) ""extern "C" struct curl_slist * __clrcall curl_slist_append(struct curl_slist *,char const *)" (?curl_slist_append@@$$J0YMPAUcurl_slist@@PAU1@PBD@Z)", auf das in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?backgroundWorker1_DoWork@Form1@freerice@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)" verwiesen wird.
   : error LNK2028: Nicht aufgelöstes Token (0A000026) ""extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" (?curl_easy_perform@@$$J0YM?AW4CURLcode@@PAX@Z)", auf das in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?backgroundWorker1_DoWork@Form1@freerice@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)" verwiesen wird.
  : error LNK2020: Nicht aufgelöstes Token (0A000027) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ).
   : error LNK2028: Nicht aufgelöstes Token (0A000028) ""extern "C" void __clrcall curl_easy_cleanup(void *)" (?curl_easy_cleanup@@$$J0YMXPAX@Z)", auf das in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?backgroundWorker1_DoWork@Form1@freerice@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)" verwiesen wird.
   : error LNK2020: Nicht aufgelöstes Token (0A00002A) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ).
 : error LNK2020: Nicht aufgelöstes Token (0A00002B) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ).
  : error LNK2020: Nicht aufgelöstes Token (0A00002C) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ).
  : error LNK2020: Nicht aufgelöstes Token (0A00002D) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ).
   : error LNK2028: Nicht aufgelöstes Token (0A00002E) ""extern "C" void * __clrcall curl_easy_init(void)" (?curl_easy_init@@$$J0YMPAXXZ)", auf das in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?backgroundWorker1_DoWork@Form1@freerice@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)" verwiesen wird.
 : error LNK2028: Nicht aufgelöstes Token (0A00002F) ""extern "C" enum CURLcode __clrcall curl_global_init(long)" (?curl_global_init@@$$J0YM?AW4CURLcode@@J@Z)", auf das in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?backgroundWorker1_DoWork@Form1@freerice@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)" verwiesen wird.
  : error LNK2001: Nicht aufgelöstes externes Symbol ""extern "C" enum CURLFORMcode __clrcall curl_formadd(struct curl_httppost * *,struct curl_httppost * *,...)" (?curl_formadd@@$$J0YM?AW4CURLFORMcode@@PAPAUcurl_httppost@@0ZZ)".
  : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""extern "C" struct curl_slist * __clrcall curl_slist_append(struct curl_slist *,char const *)" (?curl_slist_append@@$$J0YMPAUcurl_slist@@PAU1@PBD@Z)" in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?backgroundWorker1_DoWork@Form1@freerice@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)".
 : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" (?curl_easy_perform@@$$J0YM?AW4CURLcode@@PAX@Z)" in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?backgroundWorker1_DoWork@Form1@freerice@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)".
  : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""extern "C" void __clrcall curl_easy_cleanup(void *)" (?curl_easy_cleanup@@$$J0YMXPAX@Z)" in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?backgroundWorker1_DoWork@Form1@freerice@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)".
   : error LNK2001: Nicht aufgelöstes externes Symbol ""extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ)".
  : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""extern "C" void * __clrcall curl_easy_init(void)" (?curl_easy_init@@$$J0YMPAXXZ)" in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?backgroundWorker1_DoWork@Form1@freerice@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)".
 : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""extern "C" enum CURLcode __clrcall curl_global_init(long)" (?curl_global_init@@$$J0YM?AW4CURLcode@@J@Z)" in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?backgroundWorker1_DoWork@Form1@freerice@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)".
4

1 回答 1

-1

我需要包含一些与 libcurl 相关的文件,现在我没有收到任何链接器错误

于 2011-07-30T15:05:45.923 回答