gem install dm-postgres-adapter build错误
我正在尝试构建dm-postgres-adapter但是得到了这个错误。
sudo gem install dm-postgres-adapter Building native extensions. This could take a while... ERROR: Error installing dm-postgres-adapter: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb checking for main() in -lpq... yes checking for libpq-fe.h... yes checking for libpq/libpq-fs.h... yes checking for postgres.h... yes checking for mb/pg_wchar.h... no *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.
在安装postgresql并设置pg_config路径后安装pg
工作
`bundle config build.pg --with-pg-config=/usr/local/Cellar/postgresql/9.3.1/bin/pg_config`
我绝对感到困惑的是找到了postgres.h
,但没有找到pg_wchar.h,它位于同一目录/usr/local/Cellar/postgresql/9.3.1/include
设置配置选项没有帮助
--with-pgsql-server-include=/usr/local/Cellar/postgresql/9.3.1/include
我之前用macports postgresql试过这个。 有完全相同的错误后我完全卸载了mac ports并用homebrew安装postgresql。 我也试过postgresql包Postgres.app
但我总是得到这个错误。
正如我在安装pg(gem)之前所说的那样。
mkmf.log
如错误消息中所述 – “检查mkmf.log文件以获取更多详细信息。”
- 好的,我们走吧!
这对我来说绝对毫无意义。
conftest.c:5:57: error: use of undeclared identifier 'main' int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; } 1 error generated. checked program was: /* begin */ 1: #include "ruby.h" 2: 3: /*top*/ 4: extern int t(void); 5: int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; } 6: int main(int argc, char **argv) 7: { 8: if (argc > 1000000) { 9: printf("%p", &t); 10: } 11: 12: return 0; 13: } /* end */
但…
这个
/usr/local/Cellar/postgresql/9.3.1/include/server/mb/pg_wchar.h:363:14: error: function cannot return function type 'int (unsigned char *, int)' typedef bool (*mbcharacter_incrementer) (unsigned char *mbstr, int len); ^ /usr/local/Cellar/postgresql/9.3.1/include/server/mb/pg_wchar.h:388:2: error: unknown type name 'uint32' ... and lot of "unknown type name 'uint32' ...
“事情发生了可怕的错误”
找到pg_wchar.h !!!! 是啊! 但等待有错误。
修好了
typedef uint32_t uint32; // added in pg_wchat.h
但接下来是
/usr/local/Cellar/postgresql/9.3.1/include/server/mb/pg_wchar.h:364:14: error: function cannot return function type 'int (unsigned char *, int)' typedef bool (*mbcharacter_incrementer) (unsigned char *mbstr, int len);
是的,我可以通过尝试修复它,但我不认为这是正确的方法
我完全不知道该往哪里去。 所以,如果有人可以提供帮助,我会很感激。
ps:我正在使用mac os mavericks
我修好了。
我希望我能给出确切的步骤,但它是这样的:
-
从Apple开发人员站点手动更新的命令行工具。
-
卸载所有gem
-
使用brew安装rbenv,ruby-build,rbenv-bundler
-
使用brew安装apple-gcc42
-
使用rbenv安装ruby 2.1
-
设置使用rbenv的ruby的路径。
-
设置
rbenv global 2.1.0
-
已卸载的捆绑包
-
已安装捆绑
-
跑了
rbenv rehash
-
冉
sudo bundle install
成功。
来自brew info postgres,尝试在构建gem时设置ARCHFLAGS。 就像是
ARCHFLAGS="-arch x86_64" gem install pg
要么
ARCHFLAGS="-arch x86_64" gem install dm-postgres-adapter
看看是否有帮助。