Gem install dm-postgres adapter build error

I am trying to build dm-postgres-adapter, but getting 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. 

pg installation worked after installing postgresql and setting the pg_config path

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

what I'm completely confused about is that postgres.h found, but not pg_wchar.h, which is in the same /usr/local/Cellar/postgresql/9.3.1/include directory

Parameter Settings

don't help

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

I have tried this with macports postgresql before. after the same error, I completely removed the Mac ports and installed postgresql using homebrew. I also tried the postgresql package Postgres.app , but always get this error.

as I said before installing pg (gem).


mkmf.log

as the error message says: "Check the mkmf.log file for more details."

  • ok, let go!

for me it makes absolutely no sense.

 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

 /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 wrong"

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

fixed it with

 typedef uint32_t uint32; // added in pg_wchat.h 

but then the following will appear

 /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 through this and try to fix it, but I don't think this is the right way

I have absolutely no idea where to go next. Therefore, if anyone can help, I would appreciate it.

ps: i use mac os mavericks

+7
ruby gem rails-postgresql ruby-datamapper heroku-postgres
source share
2 answers

I fixed it.

I would like to give the exact steps, but it was something like this:

  • Manually updated command-line tools from the Apple Developer site.

  • All gems removed

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

  • Installed apple-gcc42 using brew

  • Installed ruby ​​2.1 using rbenv

  • Set the path to use rbenv ruby.

  • Install rbenv global 2.1.0

  • Remote package

  • Installed Package

  • ran rbenv rehash

  • Ran sudo bundle install successfully.

+3
source share

from brew info postgres, try installing ARCHFLAGS when creating 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.

+2
source share

All Articles