This is the error I get when compiling my program with the Chilkat library. I understand that I need to include the "-l" but when I include that, it gives me this:

/usr/bin/ld: cannot find -lchilkat-9.5.0
collect2: error: ld returned 1 exit status

I downloaded the Chilkat C/C++ Library from here. I don't really know how to use the .a or .so to compile my .cpp file.

This is my source code. The libraries are stored in the directory i included.

#include <iostream>
#include "chilkat/include/CkFtp2.h"
using namespace std;

int main(){
    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) {
        std::cout << ftp.lastErrorText() << "\r\n";
        return 0;
    }

    ftp.put_Hostname("ftp.someFtpServer.com");
    ftp.put_Username("****");
    ftp.put_Password("****");

    //  Connect and login to the FTP server.
    success = ftp.Connect();
    if (success != true) {
        std::cout << ftp.lastErrorText() << "\r\n";
        return 0;
    }

    //  Change to the remote directory where the file will be uploaded.
    success = ftp.ChangeRemoteDir("junk");
    if (success != true) {
        std::cout << ftp.lastErrorText() << "\r\n";
        return 0;
    }

    //  Upload a file.
    const char *localFilename = "c:/temp/hamlet.xml";
    const char *remoteFilename = "hamlet.xml";

    success = ftp.PutFile(localFilename,remoteFilename);
    if (success != true) {
        std::cout << ftp.lastErrorText() << "\r\n";
        return 0;
    }

    success = ftp.Disconnect();

    std::cout << "File Uploaded!" << "\r\n";

    return 0;
}
up vote 2 down vote accepted

I managed to compile your program with the following:

    g++ test.cpp -Lchilkat/lib -lchilkat-9.5.0 -o test

-L gives the path where the library is stored

-l gives the name of the library

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.