这是我使用 Chilkat 库编译程序时遇到的错误。我知道我需要包含“-l”,但当我包含它时,它给出了以下信息:
/usr/bin/ld: cannot find -lchilkat-9.5.0
collect2: error: ld returned 1 exit status
我从以下网址下载了 Chilkat C/C++ 库这里。我真的不知道如何使用.a 或.so 来编译我的.cpp 文件。
这是我的源代码。库存储在我包含的目录中。
#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;
}
答案1
我设法用下面的代码编译了你的程序:
g++ test.cpp -Lchilkat/lib -lchilkat-9.5.0 -o test
-L 给出库存储的路径
-l 给出库的名称