Question

I use Visual Studio 2010 on Windows 7. I have this function:

void send(char* log, char* pas, char* ser, char* plik)
{   
    HINTERNET hInternet;
    HINTERNET hFtpSession;
    hInternet = InternetOpenA(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
    hFtpSession = InternetConnectA(hInternet,ser,INTERNET_DEFAULT_FTP_PORT,log,pas, INTERNET_SERVICE_FTP, 0,0 );
    FtpPutFileA(hFtpSession, "WMM.txt", plik, FTP_TRANSFER_TYPE_BINARY, 0);
}

It didn't work:

  1. error LNK2019: unresolved external symbol "void __cdecl send(class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::basic_string<char,struct std::char_traits,class std::allocator >)" (?send@@YAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@000@Z) referenced in function _main

2)fatal error LNK1120: 1 unresolved externals

I googled for solution and found this: Add this #pragma comment(lib, "wininet") to your code or add wininet.lib in your project properties: Linker->Input

I do this and still not working - I get identical errors like earlier. Have you got any idea what I should do for resolved this problem?

Was it helpful?

Solution

Your unresolved external symbol error is for a function like this

void send(std::string log, std::string pas, std::string ser, std::string plik)

but the function you've shown us is like this

void send(char* log, char* pas, char* ser, char* plik)

I would guess that you have written the first version in your header file, and the second version in your source file. You need to be consistent, one version or the other, not both.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top