我在华硕Chromebook上通过crouton安装了Ubuntu 12.04 Precise.我有一个需要postgres的rails应用程序.当我运行"bundle"时,它无法安装pg gem.我尝试独立安装它的多个版本,但它失败了.失败报告如下:
构建原生扩展.这可能需要一段时间...错误:安装pg时出错:错误:无法构建gem原生扩展.
Run Code Online (Sandbox Code Playgroud)/home/oscar/.rvm/rubies/ruby-1.9.3-p551/bin/ruby -r ./siteconf20150331-16650-11xjo0a.rb extconf.rb checking forpg_config ... yes使用/ usr/bin/pg_config中的配置值您需要安装postgresql-server-dev-XY来构建服务器端扩展或libpq-dev来构建客户端应用程序.您需要安装postgresql-server-dev-XY来构建服务器端扩展,或者安装libpq-dev来构建客户端应用程序.检查libpq-fe.h ... no找不到'libpq-fe.h header *extconf.rb失败*由于某些原因无法创建Makefile,可能缺少必要的库和/或头文件.检查mkmf.log文件以获取更多详细信息.您可能需要配置选项.
提供的配置选项: - with-opt-dir --without-opt-dir --with-opt-include --without-opt-include = $ {opt-dir}/include --with-opt-lib - without-opt-lib = $ {opt-dir}/lib --with-make-prog --without-make-prog --srcdir =.--curdir --ruby =/home/oscar/.rvm/rubies/ruby-1.9.3-p551/bin/ruby --with-pg --without-pg --enable-windows-cross --disable-windows -cross --with-pg-config --without-pg-config --with-pg_config --with-pg_config --with-pg-dir --without-pg-dir --with-pg-include --without -pg-include = $ {pg-dir}/include --with-pg-lib --without-pg-lib = $ {pg-dir}/lib
extconf失败,退出代码1
Gem文件将保留在/home/oscar/.rvm/gems/ruby-1.9.3-p551/gems/pg-0.18.1中进行检查.结果记录到/home/oscar/.rvm/gems/ruby-1.9.3-p551/extensions/x86_64-linux/1.9.1/pg-0.18.1/gem_make.out
我也尝试使用brew安装它.下载的文件,似乎安装,但当我运行"brew upgrade postgresql"时,它说postgresql不会退出.我完全没有想法,而且我无法找到任何有问题的人.
我有一个抽象类的两个子类,每个子类实现一个超类的抽象方法.我希望每个都有不同的返回类型,尽管这些返回类型又是不同抽象类的子类.见下文:
public abstract class Gardener {
public abstract ArrayList<Flower> getFlowers();
}
public class GardererA extends Gardener {
public ArrayList<Flower> getFlowers() {
return new ArrayList<Daisy>();
}
}
public class GardererB extends Gardener {
public ArrayList<Flower> getFlowers() {
return new ArrayList<Rose>();
}
}
public abstract class Flower {}
public class Daisy extends Flower {}
public class Rose extends Flower {}
Run Code Online (Sandbox Code Playgroud)
显然Java不会让我这样做,但我对如何获得这个功能感到茫然.有任何想法吗?