C++ 如何从easy_curl返回字符串?(用于dll的函数)C++;

C++ 如何从easy_curl返回字符串?(用于dll的函数)C++;,c++,dll,libcurl,C++,Dll,Libcurl,我需要一个项目的帮助 我需要使用easy_curl创建一个DLL,我需要使用从网站到其他代码的数据。 这是DLL的代码 #include "stdafx.h" #include "Header_DLL-SIGFOX.h" #include <iostream> #include <curl/curl.h> #include <stdio.h> #include <cstdio> #include <fstream> using

我需要一个项目的帮助

我需要使用easy_curl创建一个DLL,我需要使用从网站到其他代码的数据。 这是DLL的代码

#include "stdafx.h"
#include "Header_DLL-SIGFOX.h"

#include <iostream>
#include <curl/curl.h> 
#include <stdio.h> 
#include <cstdio>
#include <fstream>

using namespace std;


namespace nmspace {
size_t writeToString(void *ptr, size_t size, size_t count, void *stream)
{
    ((string*)stream)->append((char*)ptr, 0, size* count);
    return size * count;
}

string myclass::recup(string log, string mdp, string id) {
    string usrpwd = log + ":" + mdp;
    string link = "https://" + id + "/messages";
    std::string data;

    CURL *curl;
    CURLcode res;
    curl = curl_easy_init();

    if (curl) {
        curl_easy_setopt(curl, CURLOPT_URL, link.c_str());
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_easy_setopt(curl, CURLOPT_USERPWD, usrpwd.c_str());
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeToString);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);

        res = curl_easy_perform(curl);

        if (res != CURLE_OK) {
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        }
        curl_easy_cleanup(curl);
    }
    return data;
}
当我使用它时,会出现一个错误:

Erreur  LNK2019 symbole externe non résolu "public: static int __cdecl nmspace::myclass::recup(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?recup@myclass@nmspace@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@000@Z) référencé dans la fonction _main  Test_DLL-SIGFOX C:\Users\weved\source\repos\Test_DLL-SIGFOX\Test_DLL-SIGFOX\Test_DLL-SIGFOX.obj 1   
Erreur LNK2019 symbole externe non résolu“public:static int_uucdecl nmspace::myclass::recup(class std::basic_string,class std::basic_string,class std::basic_string,class std::basic_string,class std::basic_string)”(?recup@myclass@nmspace@@SAHV?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@000@Z)référencédans la fonction_main Test_DLL-SIGFOX C:\Users\weved\source\repos\Test_DLL-SIGFOX\Test_DLL-SIGFOX\Test_DLL-SIGFOX.obj 1
“符号外部非résolu”是指:未解析的外部符号

如果我不使用返回并打印var“data”,那么代码是有效的,但是当我尝试返回数据时,没有任何效果:(

如果有人能帮助我,那就太好了:)


致以最诚挚的问候

您已导出
std::string recup
,但尚未导入它。您应该使用
\uu declspec(dllimport)
导入该函数。您是对的,我感到非常愚蠢谢谢您的帮助:)
 namespace nmspace{ 
class myclass {
public: static __declspec(dllexport) std::string recup(std::string loginSig, std::string mdpSig, std::string idSig);

public: static __declspec(dllexport) void recup2();
};
Erreur  LNK2019 symbole externe non résolu "public: static int __cdecl nmspace::myclass::recup(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?recup@myclass@nmspace@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@000@Z) référencé dans la fonction _main  Test_DLL-SIGFOX C:\Users\weved\source\repos\Test_DLL-SIGFOX\Test_DLL-SIGFOX\Test_DLL-SIGFOX.obj 1