我试图通过将 Swift 安装在 Ubuntu 服务器上来使用它作为后端。我遵循了这些说明: http://www.sitepoint.com/server-side-swift-with-perfect/ 不幸的是,当我执行以下操作时:
git clone https://github.com/PerfectlySoft/Perfect.git
cd Perfect/PerfectLib
make
sudo make install
运行“make”时出现错误。错误如下:
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "curl_support.hpp"
^
/home/chris/Perfect/PerfectLib/linked/cURL_Linux/curl_support.hpp:30:10:
error: 'curl/curl.h' file not found
#include "curl/curl.h"
^
cURL.swift:26:8: error: could not build Objective-C module 'cURL'
import cURL
我在这里尝试了所有不同的 Swift 快照: https://swift.org/download/#apple-platforms 但仍然没有。 请问有人可以帮忙吗?我正在使用 Ubuntu 14.04
最佳答案
您需要安装 curl 库才能在您的系统上使用它:)
sudo apt-get install curl
应该可以解决您的问题。
我个人使用这个 vagrantfile,它设置了我的虚拟机(所以我不会错误地弄乱我的常规 linux 设置)
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
## 1 get the ubuntu image
config.vm.box = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.provision "shell", inline: <<-SHELL
## 2 Install all necessary dependencies
sudo apt-get --assume-yes install clang libssl-dev libevent-dev libsqlite3-dev libicu-dev uuid-dev libcurl4-openssl-dev git
## 3 get the swift snapshot
curl -O https://swift.org/builds/ubuntu1404/swift-2.2-SNAPSHOT-2015-12-01-b/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz
## 4 unpack
tar zxf swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz
## 5 add swift snapshot to PATH
echo "export PATH=/home/vagrant/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/bin:\"${PATH}\"" >> .profile
echo "Swift has successfully installed on Linux"
## 5.5 create tiny script that will install all the Perfect Libs and have them accessible for the non-sudo user
echo "git clone https://github.com/PerfectlySoft/Perfect.git
cd Perfect/PerfectLib
make
sudo make install
cd ../PerfectServer
make" >> compilePerfectLib.sh
chmod a+x compilePerfectLib.sh
echo "Remember to run ./compilePerfectLib.sh after logging into the VM"
SHELL
config.vm.network :public_network #, bridge: "wlan0"
config.vm.network :forwarded_port, guest: 8181, host: 8181
config.vm.boot_timeout = 300
end
然后在你执行 vagrant ssh
并登录到 VM(虚拟机)后,你需要 sh ./compilePerfectLib.sh
这将设置你的环境:)
祝你好运!
关于ios - 使用 Swift 在 Ubuntu 上设置完美服务器时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35945516/