在10.6.7上针对libpq.a编译postgres红宝石gem

|| 我正在尝试使用自定义编译的Postgres 8.4.7安装ruby pg gem。这按预期工作:
sudo env ARCHFLAGS=\'-arch x86_64\' gem install pg -- --with-pg-config=/path/to/my/pg_config
gem可以正确编译和安装,并在需要时加载正确的动态库。 但是,我想静态链接gem,以实现在多台机器上的可移植性。我最合理的尝试:
sudo env ARCHFLAGS=\'-arch x86_64\' gem install pg -- --with-pg-config=/path/to/my/pg_config --with-ldflags=\'-static\'
失败并显示以下错误消息:
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-pg-config=/[edited]/pgsql-8.4.7/bin/pg_config --with-ldflags=-static
checking for /[edited]/pgsql-8.4.7/bin/pg_config... yes
MacOS X build: fixing architecture flags:
  using the value in ARCHFLAGS environment variable (\"-arch x86_64\").
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can\'t find the PostgreSQL client library (libpq)
有什么建议吗? 谢谢! 更新: 从mkmf.log文件:
conftest.c: In function ‘t’:
conftest.c:5: error: too few arguments to function ‘PQconnectdb’
checked program was:
/* begin */
1: #include 
2: 
3: /*top*/
4: int main() { return 0; }
5: int t() { PQconnectdb(); return 0; }
/* end */
    
已邀请:
解决了: 将Postgres静态库复制到[prefix] / lib目录的单独位置,并在构建gem时显式传递新路径:
sudo env ARCHFLAGS=\'-arch x86_64\' gem install pg -- --with-pg-config=/path/to/my/pg_config --with-pg-lib=/path/to/static/libs
细节: 关键信息在mkmf.log文件中有点:
\"gcc -o conftest -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I.  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/[edited]/pgsql-9.0.3/include -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common   conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -static -L/[edited]/pgsql-9.0.3/lib     -lruby -lpq  -lpthread -ldl  \"
ld: library not found for -lcrt0.o
collect2: ld returned 1 exit status
将\'-static \'标志传递给链接器试图创建一个完全静态链接的二进制文件,Mac OS X不支持该二进制文件: 在Mac OS X上静态链接用户二进制文件     

要回复问题请先登录注册