Quantcast

Installing OpenDBX for Postgres in Mac OS X

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Installing OpenDBX for Postgres in Mac OS X

Roberto Minelli
Hello,

I just tried to install Open DBX on my machine.

I'm using Mac OS 10.8 and Pharo 1.4.

I went through the installation–from sources–of the C openDBX driver for the Postgres database platform.

Then I loaded the OpenDBX driver for Pharo using Metacello as explained and reached the point in which I have to check if everything has installed correctly.

I changed the DBXPostgresFacility>>createConnection as requested and ran the test cases.

All test cases, but DBXConnectionSettingsTest, failed.

Do you have any hints on how to proceed?

Cheers,
Roberto M.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Installing OpenDBX for Postgres in Mac OS X

Mariano Martinez Peck


On Wed, Oct 24, 2012 at 3:53 PM, Roberto Minelli <[hidden email]> wrote:
Hello,

I just tried to install Open DBX on my machine.

I'm using Mac OS 10.8 and Pharo 1.4.

I went through the installation–from sources–of the C openDBX driver for the Postgres database platform.


Hi. Did you compile everything forcing the 32 bits compilation?
did you also install the 32 bits client library of Postgres? 
 
Then I loaded the OpenDBX driver for Pharo using Metacello as explained and reached the point in which I have to check if everything has installed correctly.

I changed the DBXPostgresFacility>>createConnection as requested and ran the test cases.


Ok

All test cases, but DBXConnectionSettingsTest, failed.


Can you provide us the stacktrace of any of the failing test?

Thanks! 
 
Do you have any hints on how to proceed?

Cheers,
Roberto M.



--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Installing OpenDBX for Postgres in Mac OS X

Roberto Minelli
Hi,

On Wednesday, October 24, 2012 4:12:10 PM UTC+2, Mariano Martinez Peck wrote:


On Wed, Oct 24, 2012 at 3:53 PM, Roberto Minelli <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="geLY_gyUluMJ">r.min...@...> wrote:
Hello,

I just tried to install Open DBX on my machine.

I'm using Mac OS 10.8 and Pharo 1.4.

I went through the installation–from sources–of the C openDBX driver for the Postgres database platform.


Hi. Did you compile everything forcing the 32 bits compilation?

I don't think so. How can I do it?
 
did you also install the 32 bits client library of Postgres? 

Hum.. Not sure.. I have to check.. However the installation guide says: If in the previous step you have installed OpenDBX by using its binaries (no compilation), then you must install the databse client library (C library) of your database.

I installed from source, thus I believe this is not an issue. Is it?
 
 
Then I loaded the OpenDBX driver for Pharo using Metacello as explained and reached the point in which I have to check if everything has installed correctly.

I changed the DBXPostgresFacility>>createConnection as requested and ran the test cases.


Ok

All test cases, but DBXConnectionSettingsTest, failed.


Can you provide us the stacktrace of any of the failing test?

It's an external error... https://dl.dropbox.com/u/6281855/external_error.png
 

Thanks! 
 
Do you have any hints on how to proceed?

Cheers,
Roberto M.



--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Installing OpenDBX for Postgres in Mac OS X

Cameron Sanders
Roberto,

I was having some troubles getting postgres/openDBX working on Mac's and hired a consultant last spring -- nice lady, not a smalltalker, but she found some solutions for me. And of the surprises that she found for me were the following: on Lion, if you have installed Xcode, then you already have a 64-bit Postgres already installed. So that obviously creates potential conflicts in library paths, as well as which binary is running and listening, etc. So my basic Postgres DB tests kept working, but my library-based access (opendbx) kept failing.

Anyway, that was the key discovery that allowed us to solve to several of our woes. One tool that greatly simplified installation of openDBX, and postgres-32bit, is called brew. It really is slick. [I have not used it in 6 months, but it worked great when I used it.]

Below I have simply cut -n- pasted the steps that this consultant (and I ) typed up to get through the install. The notes are not perfect in the presentation... as it was a scratch-pad of commands that were utilized, and once it worked, we did not scrub the document. Oh, also, please consider using Glorp if you are not already planning on it.

I hope this helps more than it confuses you!

Good luck,
Cam

Homebrew v0.9

“the easiest and most flexible way to install the UNIX tools Apple didn't include with OS X”

Install

/usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

Useful Commands

brew doctor
brew update
brew install git
brew search postgresql
brew uninstall postgresql

Notes on Cam’s mac 19apr12: already had installed git, Xcode, and Xcode command line tools

Postgres v9.1.3 as 32 bit

Really, we only want the Postgres C library libpq built as 32 bits, but we seems to have to build the whole DB that way. Building requires Xcode and Xcode command line tools.

Download, build and install

brew install -v postgresql --32-bit > ~/brew-install-postgres-32.txt
brew uninstall postgresql
brew uninstall ossp-uuid # non-32 bit had been previously installed
brew install -v postgresql --32-bit > ~/brew-install-postgres-32.txt

Set up data and logging areas

mkdir ~/postgres/data
mkdir ~/postgres/log

Initialize the database

initdb -D ~/postgres/data > ~/initdb-log.txt

Start the database

Method 1: start the database automatically

[ mkdir -p ~/Library/LaunchAgents/ ]
edit: ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist (sample in Appendix A)

Run this once:
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Here is how to unload it if a change needs to be made:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Note: we think launchctl should be run after initdb, but on 19apr12 we ran launchctl before initdb

Method 2: manually start the database (note that the log name here isn’t ideal)


  • which pg_ctl     ## confirm same as one just built
  • echo "pg_ctl -D /fullpath-to/postgres/data -l /full-path-to/postgres.log start" > start_pg
  • echo "pg_ctl -D /fullpath-to/postgres/data stop" > stop_pg
  • chmod +x start_pg stop_pg

Check that the database is running

pg_ctl status -D /usr/local/var/postgres/data
or
ps auxwww | grep postgres

Set up test user and database

[sudo su - postgres createuser --createdb --login --superuser --createrole --pwprompt sanders]

createuser sodbxtest --no-superuser --createdb --createrole
createdb sodbxtest

Optional: Load a Sample Database

For example, download: http://pgfoundry.org/projects/dbsamples/ : the USDA food database
createdb usda
psql -f usda.sql usda   ## while sitting in ~/Downloads/usda-r18-1.0/


OpenDBX v1.4.5 as 32 bit

Similar to ODBC, OpenDBX is an API for many databases like Oracle, Postgres, MySQL, etc, written in C. Its old name was SqeakDBX. This needs to be built as a 32 bit application for DBXTalk.
sample build: how a lib developer would build it
OpenDBX Website

Build and Install

mkdir ~/prog
mv ~/Downloads/opendbx-1.4.5 prog/.
cd prog/opendbx-1.4.5/
[ sudo make clean ]

#For the next CFLAGS variable, consider “-m32 -g” and/or “-m32 -O2”
CFLAGS="-m32" CXXFLAGS="-m32" CPPFLAGS="-m32" LDFLAGS="-L/usr/local/lib -m32" ./configure --with-backends="pgsql sqlite3" --disable-utils > configure-opendbx.txt

make > make-opendbx.txt
sudo make install > install-opendbx.txt

  • it seems including backend sqlite3 caused Cam troubles, and prevented the build on Win7
  • Pamela just needed LDFLAGS set to "-m32"

How to Check for a 32 bit Build

lipo -info lib/*.o

Non-fat file: libopendbx_la-odbx.o is architecture: i386

Non-fat file: libopendbx_la-odbxlib.o is architecture: i386

Non-fat file: libopendbxplus_la-odbx.o is architecture: i386

Non-fat file: libopendbxplus_la-odbx_impl.o is architecture: i386

lipo -info /usr/local/lib/libpg*

ODBXTest

The test harness included in the OpenDBX library. It requires the user create the database before running the test. Format:
Usage: ./odbxtest <options>
  -b <backend> Database backend (mysql, pgsql, sqlite, sqlite3, firebird, freetds, sybase)
  -h <server> Server name, IP address or directory
  -p <port>    Server port
  -d <database>   Database or file name
  -u <user>    User name for authentication
  -w <password>   Password for authentication
  -e           Force encrypted connection
  -r           Number of runs
  -v           Verbose mode

createdb myDatabase
cd test
./odbxtest -b pgsql -h localhost -d myDatabase > testrun.txt 2>&1
diff ref/pgsql.ref testrun.txt
[ dropdb myDatabase ]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Installing OpenDBX for Postgres in Mac OS X

Mariano Martinez Peck


On Wed, Oct 24, 2012 at 5:28 PM, Cameron Sanders <[hidden email]> wrote:
Roberto,

I was having some troubles getting postgres/openDBX working on Mac's and hired a consultant last spring -- nice lady, not a smalltalker, but she found some solutions for me. And of the surprises that she found for me were the following: on Lion, if you have installed Xcode, then you already have a 64-bit Postgres already installed. So that obviously creates potential conflicts in library paths, as well as which binary is running and listening, etc. So my basic Postgres DB tests kept working, but my library-based access (opendbx) kept failing.

Anyway, that was the key discovery that allowed us to solve to several of our woes. One tool that greatly simplified installation of openDBX, and postgres-32bit, is called brew. It really is slick. [I have not used it in 6 months, but it worked great when I used it.]

Thanks Cameron for sharing all this valuable information. I have read them all and looks correct to me. 
 Indeed, that's a common problem. Another way to solve the problem of multiple versions of the library, is to include the library in the same directory where the image/vm is. I think all OS/vms search there before going to the "known" places, so if you place them right to the image/vm you are kind of forcing with library to use. 

Using Brew is easier, but just for the note, another way is to also compile the postgres client library using the 32 bits parameter (the same used for OpenDBX). Never tried, but it should work. 
 
Also, it was always difficult for us to shared binaries for Max/Unix. For Windows, we have precompiled openDBX so you can directly download the dlls (you still need the database client library).

I hope some day we will have a real 64 bits VM with a working FFI. Right now, we need to deal with it :(

We should really improve the documentation, but the whole team (included myself) seems to be busy :(


Below I have simply cut -n- pasted the steps that this consultant (and I ) typed up to get through the install. The notes are not perfect in the presentation... as it was a scratch-pad of commands that were utilized, and once it worked, we did not scrub the document. Oh, also, please consider using Glorp if you are not already planning on it.

I hope this helps more than it confuses you!

Good luck,
Cam

Homebrew v0.9

“the easiest and most flexible way to install the UNIX tools Apple didn't include with OS X”

Install

/usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

Useful Commands

brew doctor
brew update
brew install git
brew search postgresql
brew uninstall postgresql

Notes on Cam’s mac 19apr12: already had installed git, Xcode, and Xcode command line tools

Postgres v9.1.3 as 32 bit

Really, we only want the Postgres C library libpq built as 32 bits, but we seems to have to build the whole DB that way. Building requires Xcode and Xcode command line tools.

Download, build and install

brew install -v postgresql --32-bit > ~/brew-install-postgres-32.txt
brew uninstall postgresql
brew uninstall ossp-uuid # non-32 bit had been previously installed
brew install -v postgresql --32-bit > ~/brew-install-postgres-32.txt

Set up data and logging areas

mkdir ~/postgres/data
mkdir ~/postgres/log

Initialize the database

initdb -D ~/postgres/data > ~/initdb-log.txt

Start the database

Method 1: start the database automatically

[ mkdir -p ~/Library/LaunchAgents/ ]
edit: ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist (sample in Appendix A)

Run this once:
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Here is how to unload it if a change needs to be made:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Note: we think launchctl should be run after initdb, but on 19apr12 we ran launchctl before initdb

Method 2: manually start the database (note that the log name here isn’t ideal)


  • which pg_ctl     ## confirm same as one just built
  • echo "pg_ctl -D /fullpath-to/postgres/data -l /full-path-to/postgres.log start" > start_pg
  • echo "pg_ctl -D /fullpath-to/postgres/data stop" > stop_pg
  • chmod +x start_pg stop_pg

Check that the database is running

pg_ctl status -D /usr/local/var/postgres/data
or
ps auxwww | grep postgres

Set up test user and database

[sudo su - postgres createuser --createdb --login --superuser --createrole --pwprompt sanders]

createuser sodbxtest --no-superuser --createdb --createrole
createdb sodbxtest

Optional: Load a Sample Database

For example, download: http://pgfoundry.org/projects/dbsamples/ : the USDA food database
createdb usda
psql -f usda.sql usda   ## while sitting in ~/Downloads/usda-r18-1.0/


OpenDBX v1.4.5 as 32 bit

Similar to ODBC, OpenDBX is an API for many databases like Oracle, Postgres, MySQL, etc, written in C. Its old name was SqeakDBX. This needs to be built as a 32 bit application for DBXTalk.
sample build: how a lib developer would build it
OpenDBX Website

Build and Install

mkdir ~/prog
mv ~/Downloads/opendbx-1.4.5 prog/.
cd prog/opendbx-1.4.5/
[ sudo make clean ]

#For the next CFLAGS variable, consider “-m32 -g” and/or “-m32 -O2”
CFLAGS="-m32" CXXFLAGS="-m32" CPPFLAGS="-m32" LDFLAGS="-L/usr/local/lib -m32" ./configure --with-backends="pgsql sqlite3" --disable-utils > configure-opendbx.txt

make > make-opendbx.txt
sudo make install > install-opendbx.txt

  • it seems including backend sqlite3 caused Cam troubles, and prevented the build on Win7
  • Pamela just needed LDFLAGS set to "-m32"

How to Check for a 32 bit Build

lipo -info lib/*.o

Non-fat file: libopendbx_la-odbx.o is architecture: i386

Non-fat file: libopendbx_la-odbxlib.o is architecture: i386

Non-fat file: libopendbxplus_la-odbx.o is architecture: i386

Non-fat file: libopendbxplus_la-odbx_impl.o is architecture: i386

lipo -info /usr/local/lib/libpg*

ODBXTest

The test harness included in the OpenDBX library. It requires the user create the database before running the test. Format:
Usage: ./odbxtest <options>
  -b <backend> Database backend (mysql, pgsql, sqlite, sqlite3, firebird, freetds, sybase)
  -h <server> Server name, IP address or directory
  -p <port>    Server port
  -d <database>   Database or file name
  -u <user>    User name for authentication
  -w <password>   Password for authentication
  -e           Force encrypted connection
  -r           Number of runs
  -v           Verbose mode

createdb myDatabase
cd test
./odbxtest -b pgsql -h localhost -d myDatabase > testrun.txt 2>&1
diff ref/pgsql.ref testrun.txt
[ dropdb myDatabase ]



--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Installing OpenDBX for Postgres in Mac OS X

Roberto Minelli
In reply to this post by Roberto Minelli
Thanks for the answer, but unfortunately it does not work.

I'm getting:

Error: Failure while executing: ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.2.1 --datadir=/usr/local/Cellar/postgresql/9.2.1/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.2.1/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-ossp-uuid --with-python --with-perl


On Wednesday, October 24, 2012 3:53:22 PM UTC+2, Roberto Minelli wrote:
Hello,

I just tried to install Open DBX on my machine.

I'm using Mac OS 10.8 and Pharo 1.4.

I went through the installation–from sources–of the C openDBX driver for the Postgres database platform.

Then I loaded the OpenDBX driver for Pharo using Metacello as explained and reached the point in which I have to check if everything has installed correctly.

I changed the DBXPostgresFacility>>createConnection as requested and ran the test cases.

All test cases, but DBXConnectionSettingsTest, failed.

Do you have any hints on how to proceed?

Cheers,
Roberto M.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Installing OpenDBX for Postgres in Mac OS X

Cameron Sanders
And it is not a permissions problem? (I assume you are sudo'ing or something.)

-cam

On Wed, Oct 24, 2012 at 11:52 AM, Roberto Minelli <[hidden email]> wrote:
Thanks for the answer, but unfortunately it does not work.

I'm getting:

Error: Failure while executing: ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.2.1 --datadir=/usr/local/Cellar/postgresql/9.2.1/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.2.1/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-ossp-uuid --with-python --with-perl


On Wednesday, October 24, 2012 3:53:22 PM UTC+2, Roberto Minelli wrote:
Hello,

I just tried to install Open DBX on my machine.

I'm using Mac OS 10.8 and Pharo 1.4.

I went through the installation–from sources–of the C openDBX driver for the Postgres database platform.

Then I loaded the OpenDBX driver for Pharo using Metacello as explained and reached the point in which I have to check if everything has installed correctly.

I changed the DBXPostgresFacility>>createConnection as requested and ran the test cases.

All test cases, but DBXConnectionSettingsTest, failed.

Do you have any hints on how to proceed?

Cheers,
Roberto M.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Installing OpenDBX for Postgres in Mac OS X

Roberto Minelli
Unfortunately I'm doing nothing more than 'brew install postgresql --32-bit'

R

Il giorno 24-ott-2012, alle ore 18:58, Cameron Sanders <[hidden email]> ha scritto:

And it is not a permissions problem? (I assume you are sudo'ing or something.)

-cam

On Wed, Oct 24, 2012 at 11:52 AM, Roberto Minelli <[hidden email]> wrote:
Thanks for the answer, but unfortunately it does not work.

I'm getting:

Error: Failure while executing: ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.2.1 --datadir=/usr/local/Cellar/postgresql/9.2.1/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.2.1/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-ossp-uuid --with-python --with-perl


On Wednesday, October 24, 2012 3:53:22 PM UTC+2, Roberto Minelli wrote:
Hello,

I just tried to install Open DBX on my machine.

I'm using Mac OS 10.8 and Pharo 1.4.

I went through the installation–from sources–of the C openDBX driver for the Postgres database platform.

Then I loaded the OpenDBX driver for Pharo using Metacello as explained and reached the point in which I have to check if everything has installed correctly.

I changed the DBXPostgresFacility>>createConnection as requested and ran the test cases.

All test cases, but DBXConnectionSettingsTest, failed.

Do you have any hints on how to proceed?

Cheers,
Roberto M.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Installing OpenDBX for Postgres in Mac OS X

Cameron Sanders
Roberto,

It is not clear to me whether that is acknowledgement that you forgot to sudo, that you don't have permission, or that you didn't know you should.

Before doing those commands, insert the word 'sudo'.

-Cam

On Wed, Oct 24, 2012 at 1:10 PM, Roberto Minelli [via Smalltalk] <[hidden email]> wrote:
Unfortunately I'm doing nothing more than 'brew install postgresql --32-bit'

R

Il giorno 24-ott-2012, alle ore 18:58, Cameron Sanders <[hidden email]> ha scritto:

And it is not a permissions problem? (I assume you are sudo'ing or something.)

-cam

On Wed, Oct 24, 2012 at 11:52 AM, Roberto Minelli <[hidden email]> wrote:
Thanks for the answer, but unfortunately it does not work.

I'm getting:

Error: Failure while executing: ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.2.1 --datadir=/usr/local/Cellar/postgresql/9.2.1/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.2.1/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-ossp-uuid --with-python --with-perl


On Wednesday, October 24, 2012 3:53:22 PM UTC+2, Roberto Minelli wrote:
Hello,

I just tried to install Open DBX on my machine.

I'm using Mac OS 10.8 and Pharo 1.4.

I went through the installation–from sources–of the C openDBX driver for the Postgres database platform.

Then I loaded the OpenDBX driver for Pharo using Metacello as explained and reached the point in which I have to check if everything has installed correctly.

I changed the DBXPostgresFacility>>createConnection as requested and ran the test cases.

All test cases, but DBXConnectionSettingsTest, failed.

Do you have any hints on how to proceed?

Cheers,
Roberto M.




If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/Installing-OpenDBX-for-Postgres-in-Mac-OS-X-tp4652778p4652828.html
To start a new topic under DBXTalk, email [hidden email]
To unsubscribe from DBXTalk, click here.
NAML

Loading...