PostgreSQLアダプタはまり続く

LeopardではまってCentOS5でも

[admin@localhost ~]$ sudo gem install ruby-postgres
Building native extensions.  This could take a while...
ERROR:  Error installing ruby-postgres:
	ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb install ruby-postgres
checking for main() in -lpq... yes
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for PQsetClientEncoding()... yes
checking for pg_encoding_to_char()... yes
checking for PQfreemem()... yes
checking for PQescapeString()... yes
checking for PQexecParams()... yes
creating Makefile

make
gcc -I. -I. -I/usr/lib/ruby/1.8/i686-linux -I. -DHAVE_LIBPQ_FE_H -DHAVE_LIBPQ_LIBPQ_FS_H -DHAVE_PQSETCLIENTENCODING -DHAVE_PG_ENCODING_TO_CHAR -DHAVE_PQFREEMEM -DHAVE_PQESCAPESTRING -DHAVE_PQEXECPARAMS -I/usr/local/pgsql/include  -D_FILE_OFFSET_BITS=64  -fPIC -g -O2  -Wall   -c postgres.c
postgres.c:31: error: conflicting types for 'pg_encoding_to_char'
/usr/local/pgsql/include/libpq-fe.h:518: error: previous declaration of 'pg_encoding_to_char' was here
postgres.c: In function 'pgconn_s_escape_bytea':
postgres.c:370: warning: pointer targets in passing argument 1 of 'PQescapeBytea' differ in signedness
postgres.c: In function 'pgconn_s_unescape_bytea':
postgres.c:401: warning: pointer targets in passing argument 1 of 'PQunescapeBytea' differ in signedness
make: *** [postgres.o] Error 1


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/ruby-postgres-0.7.1.2006.04.06 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/ruby-postgres-0.7.1.2006.04.06/gem_make.out

Ruby会議2008 参加しました。

スタッフ、スピーカの皆さんありがとうございました。
そして参加して盛り上げた皆さんも。

http://gihyo.jp/news/report/01/rubykaigi2008/0001
に、立派にレポートされているので、それはそれとして
個人的に一番印象に残ったのはLTの 池沢さんの
「toRubyで見つけたRubyist人生再出発」でした。

昨年のデビット・トーマスさんの「Ruby愛」の時のような
熱い思いがジーンと伝わったのです。
思わずウルっとなりました。

高橋会長が開会の辞で、「多様性は善」と言われていました。
が、まさに他の方の技術的な熱演ともひと味違った
心のこもったスピーチでした。

19日には、adobe Airコンテストの発表
http://www.computerworld.jp/topics/bcom/112549.html
も参加して「すげぇ〜」という刺激もあったのですが、
技術で到達する土俵と感動する土俵とはちょっと違うところもあるな
と実感しました。


yuguiさんには、「初めてのRuby」本にサインしてもらったし
「わからん奴は黙ってろ」名言も聞いたし、
梁山泊基調講演「技術力より求心力」のあとで
多目的ホールまつもとゆきひろさんとお話できたし、
ujihisa君や西山さんの発表も聞けたし他にもいろいろ..

かずひこさんやRuby関西の皆さんともお話できてなつかしいひとときでした。

年に1度のお祭りお祭り。

22日は、お世話になったおばさんのお葬式で神戸日帰りの為
Ruby会議には参加できませんでしたが (;_;)

ファイルコード変換

 NetBeans6.0x以降では、ファイルのデフォルトはutf8 になっている。

FaqI18nProjectEncoding
 http://wiki.netbeans.org/FaqI18nProjectEncoding

これでは、Shift_JISファイルを扱うのに不便なので、UTF8への変換スクリプトを作成しました。

 既存のShift_JISファイルをもってくる際には、to_u.rb で変換。

# 
# to_u.rb
# 引数のファイルをUTF8に変換
# 例)
#  $ ruby to_u.rb *.txt
# 元ファイルは、ファイル名+yyyymmddhhMM にて保存
# 
# 2008.6.9  FUKUI Osamu
 
require 'nkf'

# 引数ファイル群を逐次変換
ARGV.each{ |fname|
  bak = fname + Time.now.strftime("%Y%m%d%H%M") 
  # バックアップ確保
  File.rename(fname, bak)
  open(fname, "w"){|out| 
    open(bak){|from|
      while line = from.gets
        line = NKF.nkf('-m0 -w', line)
        out.print line.chomp, "\n"
      end
    }
  }
}

Shift_JISへは、 to_s.rb にて変換してやります。
改行コードはCRLFにしています。

# 
# to_s.rb
# 引数のファイルをShift_JISに変換
# 例
#  $ ruby to_s.rb *.txt
# 元ファイルは、ファイル名+yyyymmddhhMM に
# 
# 2008.6.9  FUKUI Osamu
 
require 'nkf'

# 引数ファイル群を逐次変換
ARGV.each{ |fname|
  bak = fname + Time.now.strftime("%Y%m%d%H%M") 
  # バックアップ確保
  File.rename(fname, bak)
  open(fname, "w"){|out| 
    open(bak){|from|
      while line = from.gets
        line = NKF.nkf('-m0 -s', line)
        out.print line.chomp, "\r\n"
      end
    }
  }
}

Macに移ってから euc使わなくなったので、これで変換、変換w

PostgreSQL アダプタ はまり道

ちょっとはまっているのでメモ

Building native extensions.  This could take a while...
ERROR:  Error installing postgres:
	ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install postgres --no-rdoc --no-ri --version > 0

make
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0 -I. -DHAVE_LIBPQ_FE_H -DHAVE_LIBPQ_LIBPQ_FS_H -I/opt/local/include/postgresql83  -fno-common -arch ppc -arch i386 -Os -pipe -fno-common  -c libpq-compat.c
libpq-compat.c: In function 'PQescapeBytea':
libpq-compat.c:104: warning: incompatible implicit declaration of built-in function 'sprintf'
libpq-compat.c:104: warning: pointer targets in passing argument 1 of 'sprintf' differ in signedness
libpq-compat.c: In function 'PQunescapeBytea':
libpq-compat.c:158: warning: incompatible implicit declaration of built-in function 'strlen'
libpq-compat.c:158: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness
libpq-compat.c: In function 'PQescapeBytea':
libpq-compat.c:104: warning: incompatible implicit declaration of built-in function 'sprintf'
libpq-compat.c:104: warning: pointer targets in passing argument 1 of 'sprintf' differ in signedness
libpq-compat.c: In function 'PQunescapeBytea':
libpq-compat.c:158: warning: incompatible implicit declaration of built-in function 'strlen'
libpq-compat.c:158: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0 -I. -DHAVE_LIBPQ_FE_H -DHAVE_LIBPQ_LIBPQ_FS_H -I/opt/local/include/postgresql83  -fno-common -arch ppc -arch i386 -Os -pipe -fno-common  -c postgres.c
postgres.c:41: error: static declaration of 'PQserverVersion' follows non-static declaration
/opt/local/include/postgresql83/libpq-fe.h:262: error: previous declaration of 'PQserverVersion' was here
postgres.c:41: error: static declaration of 'PQserverVersion' follows non-static declaration
/opt/local/include/postgresql83/libpq-fe.h:262: error: previous declaration of 'PQserverVersion' was here
postgres.c: In function 'Init_postgres':
postgres.c:2676: error: 'pgconn_protocol_version' undeclared (first use in this function)
postgres.c:2676: error: (Each undeclared identifier is reported only once
postgres.c:2676: error: for each function it appears in.)
postgres.c:2677: error: 'pgconn_server_version' undeclared (first use in this function)
postgres.c: In function 'Init_postgres':
postgres.c:2676: error: 'pgconn_protocol_version' undeclared (first use in this function)
postgres.c:2676: error: (Each undeclared identifier is reported only once
postgres.c:2676: error: for each function it appears in.)
postgres.c:2677: error: 'pgconn_server_version' undeclared (first use in this function)
lipo: can't open input file: /var/folders/0J/0JkmgbYCHTygjWSmQI1vL++++TI/-Tmp-//cccMThQY.out (No such file or directory)
make: *** [postgres.o] Error 1


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/postgres-0.7.9.2008.01.28 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/postgres-0.7.9.2008.01.28/ext/gem_make.out

JRuby でも

Building native extensions.  This could take a while...
ERROR:  Error installing postgres:
	ERROR: Failed to build gem native extension.

/Users/ofukui/Desktop/jruby-1.1RC3/bin/jruby extconf.rb install postgres --no-rdoc --no-ri --version > 0


Gem files will remain installed in /Users/ofukui/Desktop/jruby-1.1RC3/lib/ruby/gems/1.8/gems/postgres-0.7.9.2008.01.28 for inspection.
Results logged to /Users/ofukui/Desktop/jruby-1.1RC3/lib/ruby/gems/1.8/gems/postgres-0.7.9.2008.01.28/ext/gem_make.out

コマンドライン直でも

$ sudo jruby -S gem install ruby-postgres -- --with-pgsql-include-dir=/usr/local/pgsql --with-pgsql-lib-dir=/usr/local/libPassword:
Building native extensions.  This could take a while...
extconf.rb:6:in `require': no such file to load -- mkmf (LoadError)
	from extconf.rb:6
ERROR:  Error installing ruby-postgres:
	ERROR: Failed to build gem native extension.

/Users/ofukui/Desktop/jruby-1.1RC3/bin/jruby extconf.rb install ruby-postgres -- --with-pgsql-include-dir=/usr/local/pgsql --with-pgsql-lib-dir=/usr/local/lib


Gem files will remain installed in /Users/ofukui/Desktop/jruby-1.1RC3/lib/ruby/gems/1.8/gems/ruby-postgres-0.7.1.2006.04.06 for inspection.
Results logged to /Users/ofukui/Desktop/jruby-1.1RC3/lib/ruby/gems/1.8/gems/ruby-postgres-0.7.1.2006.04.06/gem_make.out

portsでインストール

すんなり以下でいけました。

$ sudo port -k install postgresql83

しかしながらモジュールの方は

$ sudo gem install postgres -- --with-pgsql-include-dir=/opt/local/include/postgresql83 --with-pgsql-lib-dir=/opt/local/lib/postgresql83

ではすんなりいかず

$ sudo gem install postgres-pr

にて代替中。