gem install dm-postgres-adapter build error
Asked Answered
R

2

7

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

Reckoning answered 15/11, 2013 at 10:27 Comment(1)
I'm also facing this issue. Searching I've found out that cloud be possibly due to the new compiler that came with the new version of Xcode. Do you have any update on this? :(Palpate
P
3

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.

Pendergast answered 23/3, 2014 at 12:47 Comment(0)
D
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.

Drug answered 23/3, 2014 at 2:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.