I have downloaded the ftp library files from http://www.example-code.com/vcpp/ftp_passiveUpload.asp

And set it in my code:

#include "stdafx.h"
#include "iostream"
#include <CkFtp2.h>

void ChilkatSample(void)

int main(){
ChilkatSample();
return 0;
}

void ChilkatSample(void)
{
CkFtp2 ftp;

bool success;

//  Any string unlocks the component for the 1st 30-days.
success = ftp.UnlockComponent("Anything for 30-day trial");
if (success != true) {
    printf("%s\n",ftp.lastErrorText());
    return;
}

ftp.put_Hostname("www.example-code.com");
ftp.put_Username("***");
ftp.put_Password("***");

//  Use Passive mode.
ftp.put_Passive(true);

//  Connect and login to the FTP server.
success = ftp.Connect();
if (success != true) {
    printf("%s\n",ftp.lastErrorText());
    return;
}

//  Change to the remote directory where the file will be uploaded.
success = ftp.ChangeRemoteDir("junk");
if (success != true) {
    printf("%s\n",ftp.lastErrorText());
    return;
}

//  Upload a file.
const char * localFilename;                //The local file exists already
localFilename = "hamlet.xml";
const char * remoteFilename;
remoteFilename = "hamlet.xml";

success = ftp.PutFile(localFilename,remoteFilename);
if (success != true) {
    printf("%s\n",ftp.lastErrorText());
    return;
}

ftp.Disconnect();

printf("File Uploaded!\n");
}

But when i compile the program it give the error:

error LNK2019: unresolved external symbol "public: void __thiscall CkFtp2::put_Username(char const *)" (?put_Username@CkFtp2@@QAEXPBD@Z) referenced in function "void __cdecl ChilkatSample(void)" (?ChilkatSample@@YAXXZ)

Recommended Answers

All 2 Replies

But when i compile the program it give the error:

what Error(s)? post the error messages

what compiler and operating system are you using?

It's not enough to just include a header. You have included a header, which tells the compiler enough basic facts about the function named CkFtp2::put_Username to know what its name is, what input parameters it takes, and what return it gives. The compiler has enough information to essentially put a note there for the linker, saying "Dear Linker, please link my code here to the function named CkFtp2::put_Username that you will find either somewhere else in my code, or in a library".

But you still need to provide the actual function. You can do this in one of two ways. Either you write it yourself, which is not what you want to do in this case, or you get the built library containing that function and you tell your linker to look in that library for the function.

You've misunderstood what a header is for, and what a library is for.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.