2011-07-30 27 views
-1

链接错误,包括我和使用libcurl的一个项目,我得到这个错误与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); 
} 

link error LNK2031

link error LNK2019 和其他

: error LNK2031: p/invoke konnte nicht für ""extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" ([email protected]@[email protected]@[email protected]@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 * *,...)" ([email protected]@[email protected]@[email protected]@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 *)" ([email protected]@[email protected]@[email protected]@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 *)" ([email protected]@[email protected]@[email protected])" generiert werden. In den Metadaten fehlt die Aufrufkonvention. 
    : error LNK2031: p/invoke konnte nicht für ""extern "C" void __clrcall curl_easy_cleanup(void *)" ([email protected]@[email protected])" generiert werden. In den Metadaten fehlt die Aufrufkonvention. 
    : error LNK2031: p/invoke konnte nicht für ""extern "C" void * __clrcall curl_easy_init(void)" ([email protected]@$$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)" ([email protected]@[email protected]@[email protected])" 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,...)" ([email protected]@[email protected]@[email protected]@ZZ). 
    : error LNK2020: Nicht aufgelöstes Token (0A00001A) "extern "C" enum CURLFORMcode __clrcall curl_formadd(struct curl_httppost * *,struct curl_httppost * *,...)" ([email protected]@[email protected]@[email protected]@0ZZ). 
    : error LNK2020: Nicht aufgelöstes Token (0A00001B) "extern "C" enum CURLFORMcode __clrcall curl_formadd(struct curl_httppost * *,struct curl_httppost * *,...)" ([email protected]@[email protected]@[email protected]@0ZZ). 
    : error LNK2020: Nicht aufgelöstes Token (0A000020) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" ([email protected]@[email protected]@[email protected]@ZZ). 
    : error LNK2028: Nicht aufgelöstes Token (0A000021) ""extern "C" struct curl_slist * __clrcall curl_slist_append(struct curl_slist *,char const *)" ([email protected]@[email protected]@[email protected]@Z)", auf das in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" ([email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@Z)" verwiesen wird. 
    : error LNK2028: Nicht aufgelöstes Token (0A000026) ""extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" ([email protected]@[email protected]@[email protected])", auf das in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" ([email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@Z)" verwiesen wird. 
    : error LNK2020: Nicht aufgelöstes Token (0A000027) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" ([email protected]@[email protected]@[email protected]@ZZ). 
    : error LNK2028: Nicht aufgelöstes Token (0A000028) ""extern "C" void __clrcall curl_easy_cleanup(void *)" ([email protected]@[email protected])", auf das in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" ([email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@Z)" verwiesen wird. 
    : error LNK2020: Nicht aufgelöstes Token (0A00002A) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" ([email protected]@[email protected]@[email protected]@ZZ). 
: error LNK2020: Nicht aufgelöstes Token (0A00002B) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" ([email protected]@[email protected]@[email protected]@ZZ). 
    : error LNK2020: Nicht aufgelöstes Token (0A00002C) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" ([email protected]@[email protected]@[email protected]@ZZ). 
    : error LNK2020: Nicht aufgelöstes Token (0A00002D) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" ([email protected]@[email protected]@[email protected]@ZZ). 
    : error LNK2028: Nicht aufgelöstes Token (0A00002E) ""extern "C" void * __clrcall curl_easy_init(void)" ([email protected]@$$J0YMPAXXZ)", auf das in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" ([email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@Z)" verwiesen wird. 
: error LNK2028: Nicht aufgelöstes Token (0A00002F) ""extern "C" enum CURLcode __clrcall curl_global_init(long)" ([email protected]@[email protected]@[email protected])", auf das in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" ([email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@Z)" verwiesen wird. 
    : error LNK2001: Nicht aufgelöstes externes Symbol ""extern "C" enum CURLFORMcode __clrcall curl_formadd(struct curl_httppost * *,struct curl_httppost * *,...)" ([email protected]@[email protected]@[email protected]@0ZZ)". 
    : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""extern "C" struct curl_slist * __clrcall curl_slist_append(struct curl_slist *,char const *)" ([email protected]@[email protected]@[email protected]@Z)" in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" ([email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@Z)". 
: error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" ([email protected]@[email protected]@[email protected])" in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" ([email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@Z)". 
    : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""extern "C" void __clrcall curl_easy_cleanup(void *)" ([email protected]@[email protected])" in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" ([email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@Z)". 
    : error LNK2001: Nicht aufgelöstes externes Symbol ""extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" ([email protected]@[email protected]@[email protected]@ZZ)". 
    : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""extern "C" void * __clrcall curl_easy_init(void)" ([email protected]@$$J0YMPAXXZ)" in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" ([email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@Z)". 
: error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""extern "C" enum CURLcode __clrcall curl_global_init(long)" ([email protected]@[email protected]@[email protected])" in Funktion ""private: void __clrcall freerice::Form1::backgroundWorker1_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" ([email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@Z)". 
+0

@mu太短:将C++函数传递给C库不是问题,因为传递的函数指针不是名称所以名字在这里不会造成麻烦。 – Eelke

+0

@mu:我的德语很棒,可以阅读。第一个::错误LNK2031:无法为XYZ生成p/invoke。调用约定从元数据中缺失。“对我来说,这似乎与我并不熟悉的cli有关。 – Eelke

+0

@mu:基本上有三组消息。最后一组可能来自缺失的卷曲库。但-lcurl可能不适用于Visual Studio。第三篇文章在以下网页http://www.kirupa.com/forum/showthread.php?273849-Studio-Visual-C-Adding-(.lib)-refrence!解释如何添加一个库。 – Eelke

回答

-1

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