Search code examples
postgresqlaixlibpqxlc

How build 64-bit version of libpq from source code?


I'm trying connect to PostgreSQL from C-code, and i have to build libpq from source, because i'm on AIX. I followed the steps in this comment Where do i get libpq source? but in result i got a 32-bit version of libpq.a, how build 64-bit version?


Solution

  • Compiling on AIX is harder than on other platforms... Always create a script which you gradually improve till you get a working version. Possible start:

    #!/bin/sh
    
    #assuming gcc
    GCCLIB=$(dirname $(gcc -maix64 -pthread -print-file-name=libgcc_s.a))
    export CFLAGS='-maix64 -mtune=native -pthread'
    export CPPFLAGS='-D_GNU_SOURCE -D_XOPEN_SOURCE=500 -D_ALL_SOURCE'
    export LDFLAGS="-maix64 -Wl,-brtl -Wl,-blibpath:/usr/local/lib64:${GCCLIB}:/usr/lib -L/usr/local/lib64 -pthread"
    export OBJECT_MODE=64
    
    ./configure --prefix=/usr/local \
        --libdir=/usr/local/lib64   \
        --enable-shared             \
        --enable-static             \
        2>&1 | tee log.configure
    
    make all 2>&1 | tee log.make.all
    make install 2>&1 | tee log.make.install