1

I'm trying to upgrade a (proprietary, closed-source, legacy) database-driven application from using PostgreSQL 8.1 to PostgreSQL 9.4. I have it installed on a virtual machine running CentOS 5.9. Here's a rough summary of what I've done so far:

  1. Downloaded and installed the PostgreSQL 9.4 RPM package from yum.postgresql.org:

    $ wget http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/pgdg-centos94-9.4-1.noarch.rpm
    $ yum install pgdg-redhat94-9.4-1.noarch.rpm
    
  2. Installed all the postgresql94 packages:

    $ sudo yum install postgresql94*
    
  3. Dumped my current database to a file:

    $ sudo su postgres
    $ pg_dumpall > dump.sql
    
  4. Uninstalled the the old postgresql packages:

    $ sudo yum remove postgresql postgresql-*
    
  5. Sym-linked the new postgres94 bin directory to the location of the old postgres bin directory:

    $ sudo ln -s /usr/pgsql-9.4/bin/ /usr/bin/pgsql
    
  6. Initialized a postgres94 database and loaded the dump file:

    $ /etc/init.d/postgresql-9.4 initdb
    $ /etc/init.d/postgresql-9.4 start
    $ /usr/pgsql-9.4/bin/psql < dump.sql
    

Then I tried to run the application. For the most part it seemed to work, but it had a few quirks. After a brief attempt at debugging I realized that the application was also using the PostgreSQL C API. So I tried to re-compile the program:

  1. Reconfigure:

    $ ./configure
    
  2. Check that the include directories and the library directories are configured correctly:

    $ cat Makefile | grep -P '\-I|\-L'
    
    PG_CFLAGS = -I/usr/pgsql-9.4/include
    PG_CFLAGS_SERVER = -I/usr/pgsql-9.4/include/server
    PG_CXXFLAGS = -I/usr/pgsql-9.4/include
    PG_CXXFLAGS_SERVER = -I/usr/pgsql-9.4/include/server
    PG_LDFLAGS = -L/usr/pgsql-9.4/lib
    
  3. Double-check the postgres include and library directories:

    $ pg_config --includedir
    
    /usr/pgsql-9.4/include
    
    $ pg_config --libdir
    
    /usr/pgsql-9.4/lib
    
  4. Recompile:

    $ make clean
    $ make > make.out 2> make.err
    
  5. Check error output:

    $ cat make.err
    /usr/bin/ld: cannot find -lpq
    collect2: ld returned 1 exit status
    [...]
    make[2]: *** [all] Error 2
    make[1]: *** [all-recursive] Error 1
    make: *** [all-recursive] Error 1
    

So it looks like the linker can't find the libpq library, but I'm not sure why. Help?

2
  • 1
    Are you sure the app's configure actually respects pg_config? check config.log to see what libdir it's finding, which pg_config it used, etc. Also consider removing configure's cache and doing a make clena. Jul 25, 2015 at 9:19
  • I'm looking through config.log, but I don't see any other -I or -L directives. I also don't see any evidence of /usr/lib being in the path, even though the linker does seem to be finding /usr/lib.
    – igal
    Jul 25, 2015 at 14:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.