gem install dm-postgres-adapter build error

笑着哭i 提交于 2019-12-04 11:27:24

问题


i'm trying to build dm-postgres-adapter but get this error.

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.

installing pg worked after installing postgresql and setting pg_config path

`bundle config build.pg --with-pg-config=/usr/local/Cellar/postgresql/9.3.1/bin/pg_config`

what i am absolutly confused about is that postgres.his found, but not pg_wchar.h which is in the same directory /usr/local/Cellar/postgresql/9.3.1/include

setting configuration options doesnt help

--with-pgsql-server-include=/usr/local/Cellar/postgresql/9.3.1/include

i've tried this with macports postgresql before. after having the same error i've completly uninstalled mac ports and install postgresql with homebrew. I also tried the postgresql package Postgres.app but i get always the this error.

as i said before installing pg (gem) worked.


mkmf.log

as said in error message - "Check the mkmf.log file for more details."

  • ok, lets go!

this makes absolutely no sense to me.

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 */

but...

this one

/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' ...

"Something went horribly wrong"

pg_wchar.h is found!!!! yeah! but wait there is an error.

fixed it with

typedef uint32_t uint32; // added in pg_wchat.h

but then comes the next

/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);

yes, i could go this through and trying to fix it, but i don't think that this is the right way

i have absolutely no idea where to go on. So if somebody could help i would appreciate it.

ps: i am using mac os mavericks


回答1:


I fixed this.

I wish I could give exact steps, but it was something like this:

  • Manually updated Command Line Tools from the apple developer site.

  • Uninstalled all gems

  • Installed rbenv, ruby-build, rbenv-bundler using brew

  • Installed apple-gcc42 using brew

  • Installed ruby 2.1 using rbenv

  • Set path to use rbenv's ruby.

  • Set rbenv global 2.1.0

  • Uninstalled bundle

  • Installed bundle

  • ran rbenv rehash

  • Ran sudo bundle install successfully.




回答2:


from brew info postgres, try setting ARCHFLAGS when building the gem. something like

 ARCHFLAGS="-arch x86_64" gem install pg

or

  ARCHFLAGS="-arch x86_64" gem install dm-postgres-adapter 

and see if that helps.



来源:https://stackoverflow.com/questions/19998879/gem-install-dm-postgres-adapter-build-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!