【问题标题】:Error setting up a Perfect server on Ubuntu using Swift使用 Swift 在 Ubuntu 上设置 Perfect 服务器时出错
【发布时间】:2016-03-11 16:42:18
【问题描述】:
我试图通过在 Ubuntu 服务器上安装 Swift 作为后端。我按照以下说明进行操作:
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
【问题讨论】:
标签:
ios
swift
ubuntu
perfect
【解决方案1】:
您需要安装 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 这将设置您的环境:)
祝你好运!