我需要从 ftp 上传、删除和下载文件。我尝试查看许多库,发现这是最合适的。我下载了项目的源代码,并在我的项目文件夹中添加了这些头文件和 cpp 文件。我也将该路径添加到我的搜索目录中。然后我写了这个简单的程序来测试和上传文件:
#include <ftpclient.h>
using namespace std;
int main(){
nsFTP::CFTPClient ftpClient;
nsFTP::CLogonInfo logonInfo("localhost", 21, "anonymous",
"anonymous@user.com");
ftpClient.Login(logonInfo);
ftpClient.UploadFile(_T("D:\\file.txt"), _T("/upload/test.txt"));
ftpClient.Logout();
return 0;
}
我收到以下错误:
obj\Debug\main.o||在函数
main':| D:\Projects\FTP\main.cpp|4|undefined reference to
nsSocket::CreateDefaultBlockingSocketInstance()'| D:\Projects\FTP\main.cpp|4|未定义对nsFTP::CFTPClient::CFTPClient(std::auto_ptr<nsSocket::IBlockingSocket>, unsigned int, unsigned int, unsigned int, std::string const&)'| D:\Projects\FTP\main.cpp|4|undefined reference to
nsFTP::CFTPClient::~CFTPClient()'的引用 D:\Projects\FTP\main.cpp|4|未定义对nsFTP::CFTPClient::~CFTPClient()'| D:\Projects\FTP\main.cpp|4|undefined reference to
nsFTP::CFTPClient::~CFTPClient()'的引用 D:\Projects\FTP\main.cpp|6|未定义对nsFTP::CLogonInfo::CLogonInfo(std::string const&, unsigned short, std::string const&, std::string const&, std::string const&)'| D:\Projects\FTP\main.cpp|9|undefined reference to
nsFTP::CFTPClient::Login(nsFTP::CLogonInfo const&)'的引用 D:\Projects\FTP\main.cpp|12|未定义对nsFTP::CFTPClient::UploadFile(std::string const&, std::string const&, bool, nsFTP::CRepresentation const&, bool) const'| D:\Projects\FTP\main.cpp|14|undefined reference to
nsFTP::CFTPClient::Logout()'的引用 D:\Projects\FTP\main.cpp|15|未定义对nsFTP::CFTPClient::~CFTPClient()'| D:\Projects\FTP\main.cpp|15|undefined reference to
nsFTP::CFTPClient::~CFTPClient()'的引用 ||=== 构建完成:11 个错误,0 个警告 ===|
我究竟做错了什么?我应该怎么做才能正确运行程序?