我找到了这个库 https://github.com/embeddedmz/ftpclient-cpp在 GitHub 上,但如何在 Linux(Ubuntu) 上安装它却非常晦涩难懂。
You will need CMake to generate a makefile for the static library or to build the tests/code coverage program. Also make sure you have libcurl and Google Test installed.
You can follow this script https://gist.github.com/fideloper/f72997d2e2c9fbe66459 to install libcurl.
This tutorial will help you installing properly Google Test on Ubuntu: https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/
The CMake script located in the tree will produce Makefiles for the creation of the static library and for the unit tests program.
To create a debug static library and a test binary, change directory to the one containing the first CMakeLists.txt and :
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE:STRING=Debug
make
我不清楚“包含第一个 CMakeLists.txt 的那个”指的是什么。它是Gtest中的那个吗? curl 的那个?或者是什么?在尝试了这两种方法(Gtest 和 Curl 中的 Cmake)之后,我仍然收到错误消息:“No such file or directory”,同时尝试 #include "FTPClient.h"。
更新:
列出我在做什么:
我做了
git clone https://github.com/embeddedmz/ftpclient-cpp.git
然后创建构建文件夹,导航到它,我尝试了 cmake .. -DCMAKE_BUILD_TYPE:STRING=Debug
(这是我插入的文字命令),我得到Cmake Error at CmakeLists.txt: 27 (add_subdirectory): add_subdirectory given source "TestFTP" which is not an existing directory
那么到目前为止有什么问题?
最佳答案
建库后会有libftpclient.a
在您的构建树中生成。
您可以按如下方式将其安装到您的系统中:
在这种情况下,复制 libftpclient.a
至/usr/local/lib
和 FTP
中的两个头文件至/usr/local/include
.
然后您应该能够通过添加 -I/usr/local/include
来包含头文件。通过添加 -L/usr/local/lib -lftpclient
标记和链接.
关于c++ - 在 C++ Ubuntu 中安装 FTP 客户端(库),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68937369/