c++solaris-10libpqxxsolaris-studio

Error when attempting to compile libpqxx-4.0.1 on Solaris 10 using Oracle Solaris Studio 12.3


Problem description

I am unable to compile libpqxx-4.0.1 on Solaris 10 using Solaris Studio 12.3.

Background

The first thing I did when I needed libpqxx was to search for it in OpenCSW using /opt/csw/bin/pkgutil -a libpqxx. However, the package in OpenCSW is listed as being version "5.0,REV=2012.05.06" and looking at CSWlibpqxx5-0 on the OpenCSW website seems to indicate that this is an old, unstable snapshot. I would like a stable version.

I downloaded libpqxx-4.0.1.tar.gz from the libpqxx website and compiled it. It was compiled with g++ since I had it and other tools in my $PATH. It worked. Everything was coming along nicely. I was able to SELECT from my database and so on.

I then got to the stage which was most important for my code; to communicate with a proprietary C++ API. My code would no longer compile with g++ after I attempted to link to the libraries for this API. The API includes examples which I had previously compiled using CC. The examples do not compile using g++. I figured that I'd have to compile my code using CC as well, instead of using g++. My code would not compile using CC. There was something with the g++ compiled libpqxx-4.0.1 that CC did not like.

Thus, I decided that I'd need to compile libpqxx-4.0.1 using CC also, instead of using g++.

Steps taken

To eliminate problems caused by a potentially misconfigured environment (I've been using my account on the system since 2012 and over time, various environment variables and such have accumulated), I created a new user on the system with a clean home directory.

Below is a transcript of what I did next, leading up to the build error.

-bash-3.2$ pwd

/var/tmp/build

-bash-3.2$ ls -al

total 3506
drwxr-xr-x   3 build    build          6 Oct 22 13:23 .
drwxrwxrwt  45 root     sys          601 Oct 22 13:22 ..
-rw-------   1 build    build          0 Oct 22 13:23 .bash_history
drwxr-xr-x   2 build    build          2 Oct 22 12:57 install_test
-rw-r--r--   1 build    build    1582532 Oct 22 12:54 libpqxx-4.0.1.tar.gz
-rwxr-xr-x   1 build    build       4924 Oct 22 13:02 splitconfig

-bash-3.2$ /usr/sfw/bin/gtar xf libpqxx-4.0.1.tar.gz

Python 2.4.6, the /usr/bin/python in Solaris 10 had trouble with a script so I did a quick and dirty patch.

-bash-3.2$ diff libpqxx-4.0.1/tools/splitconfig splitconfig

1c1
< #! /usr/bin/python
---
> #! /opt/csw/bin/python2.7

-bash-3.2$ cp splitconfig libpqxx-4.0.1/tools/

My $PATH at this point is only /usr/bin.

-bash-3.2$ echo $PATH

/usr/bin:

I need ld. It is found in /usr/ccs/bin.

-bash-3.2$ export PATH=$PATH:/usr/ccs/bin

CC is from Oracle Solaris Studio 12.3. (See details under heading additional information.)

-bash-3.2$ which CC

/usr/bin/CC

-bash-3.2$ cd libpqxx-4.0.1

-bash-3.2$ ./configure --prefix=/var/tmp/build/install_test --enable-shared --enable-documentation

checking for a BSD-compatible install... config/install-sh -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... nawk
checking whether make sets $(MAKE)... yes
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... CC
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... no
checking whether CC accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of CC... none
checking for gcc... no
checking for cc... cc
checking whether we are using the GNU C compiler... no
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking dependency style of cc... none
checking build system type... i386-pc-solaris2.10
checking host system type... i386-pc-solaris2.10
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/xpg4/bin/grep
checking for egrep... /usr/xpg4/bin/grep -E
checking for fgrep... /usr/xpg4/bin/grep -F
checking for non-GNU ld... /usr/ccs/bin/ld
checking if the linker (/usr/ccs/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/ccs/bin/nm -p
checking the name lister (/usr/ccs/bin/nm -p) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786240
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert i386-pc-solaris2.10 file names to i386-pc-solaris2.10 format... func_convert_file_noop
checking how to convert i386-pc-solaris2.10 file names to toolchain format... func_convert_file_noop
checking for /usr/ccs/bin/ld option to reload object files... -r
checking for objdump... no
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/ccs/bin/nm -p output from cc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... cc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking for cc option to produce PIC... -KPIC -DPIC
checking if cc PIC flag -KPIC -DPIC works... yes
checking if cc static flag -Bstatic works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/ccs/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... solaris2.10 ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... no
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... CC -E
checking whether the CC linker (/usr/ccs/bin/ld) supports shared libraries... yes
checking for CC option to produce PIC... -KPIC -DPIC
checking if CC PIC flag -KPIC -DPIC works... yes
checking if CC static flag -Bstatic works... yes
checking if CC supports -c -o file.o... yes
checking if CC supports -c -o file.o... (cached) yes
checking whether the CC linker (/usr/ccs/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... solaris2.10 ld.so
checking how to hardcode library paths into programs... immediate
checking whether make sets $(MAKE)... (cached) yes
checking for mkdir... /usr/bin/mkdir
checking for pkg-config... /usr/bin/pkg-config
checking for doxygen... no
checking for dot... NO
checking for xmlto... no
checking whether to enable maintainer-specific portions of Makefiles... no
checking maintainer mode...
checking name of standard library namespace (normally "std")... ::std
checking boost/smart_ptr.hpp usability... no
checking boost/smart_ptr.hpp presence... no
checking for boost/smart_ptr.hpp... no
checking whether TR1 headers live in tr1 directory... no
checking namespace of TR1 extension to the C++ standard... std
checking ios usability... yes
checking ios presence... yes
checking for ios... yes
checking streambuf usability... yes
checking streambuf presence... yes
checking for streambuf... yes
checking locale usability... yes
checking locale presence... yes
checking for locale... yes
checking locale function and stringstream::imbue... yes
checking char_traits template... yes
checking "warning" preprocessor directive... yes
checking "message" preprocessor pragma... yes
checking for pg_config... /usr/bin/pg_config
configure: using PostgreSQL headers at /usr/include/pgsql
configure: using PostgreSQL libraries at /usr/lib
checking for ANSI C header files... (cached) yes
checking ability to compile programs using the standard C library... yes
checking for library containing select... none required
checking /usr/include/pgsql/libpq-fe.h usability... yes
checking /usr/include/pgsql/libpq-fe.h presence... yes
checking for /usr/include/pgsql/libpq-fe.h... yes
checking for ability to compile source files using libpq... yes
checking for main in -lpq... yes
checking for PQexec in -lpq... yes
checking for correct C++ linkage of basic libpq functions... yes
checking that type of libpq's Oid is as expected... yes
checking lo_tell()... yes
checking for strerror_r... no
configure: WARNING:
No definition of strerror_r, the thread-safe version of strerror(), was found in
your <cstring> header.

This may be because your implementation strerror() is threadsafe, in which case
there is nothing to worry about.

checking for strnlen... no
checking for strlcpy... no
checking for long long... yes
checking for long double... yes
checking for working <sys/select.h>... yes
checking for poll()... yes
checking for working fd_set... yes
checking if select() accepts NULL fdsets... yes
checking sleep()... yes
checking PQisthreadsafe()... no
checking PQescapeLiteral()... no
checking support for hex binary escaping format... no
checking PQescapeIdentifier()... pqescapeidentifier
checking PQencryptPassword()... no
checking PQmblen()... yes
checking PQdescribePortal()... no
checking PQclientEncoding()... yes
checking PQcancel()... yes
checking limits usability... yes
checking limits presence... yes
checking for limits... yes
checking for C99 isnan()... no
checking for std::numeric_limits<>::quiet_NaN()... yes
checking for C NAN macro... no
checking for C99 nan() family... no
checking for C99 isinf()... no
checking whether std::string has a clear() function... yes
checking for standard distance()... no
checking if count_if() works as expected... no
checking whether <iterator> defines a usable iterator template... yes
checking for reverse_iterator template... no
checking for auto_ptr... yes
checking for tr1::shared_ptr... no
checking for unique_ptr... no
checking for move()... no
checking whether overloaded using-declarations work... yes
checking whether make sets $(MAKE)... (cached) yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config/Makefile
config.status: creating debian/Makefile
config.status: creating doc/Makefile
config.status: creating doc/Doxyfile
config.status: creating src/Makefile
config.status: creating test/Makefile
config.status: creating test/unit/Makefile
config.status: creating tools/Makefile
config.status: creating win32/Makefile
config.status: creating include/Makefile
config.status: creating include/pqxx/Makefile
config.status: creating libpqxx.pc
config.status: creating pqxx-config
config.status: creating libpqxx.spec
config.status: creating include/pqxx/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing configitems commands
Generating include/pqxx/config-internal-autotools.h: 7 item(s).
Generating include/pqxx/config-internal-compiler.h: 10 item(s).
Generating include/pqxx/config-internal-libpq.h: 4 item(s).
Generating include/pqxx/config-public-autotools.h: no items--skipping.
Generating include/pqxx/config-public-compiler.h: 11 item(s).
Generating include/pqxx/config-public-libpq.h: no items--skipping.

make from /usr/ccs/bin was unable to build it earlier so now I try using dmake from Oracle Solaris Studio 12.3.

-bash-3.2$ which make

/usr/ccs/bin/make

-bash-3.2$ which dmake

/usr/bin/dmake

-bash-3.2$ dmake

dmake: defaulting to parallel mode.
See the man page dmake(1) for more information on setting up the .dmakerc file.
Making all in include
Making all in pqxx
dmake  all-am
Making all in src
develop --> 1 job
source='binarystring.cxx' object='binarystring.lo' libtool=yes \
DEPDIR=.deps depmode=none /bin/bash ../config/depcomp \
/bin/bash ../libtool --tag=CXX    --mode=compile CC -DHAVE_CONFIG_H  -I../include -I../include -I/usr/include/pgsql     -g -c -o binarystring.lo binarystring.cxx
develop --> 2 jobs
source='connection_base.cxx' object='connection_base.lo' libtool=yes \
DEPDIR=.deps depmode=none /bin/bash ../config/depcomp \
/bin/bash ../libtool --tag=CXX    --mode=compile CC -DHAVE_CONFIG_H  -I../include -I../include -I/usr/include/pgsql     -g -c -o connection_base.lo connection_base.cxx
develop --> Job output
source='connection_base.cxx' object='connection_base.lo' libtool=yes \
DEPDIR=.deps depmode=none /bin/bash ../config/depcomp \
/bin/bash ../libtool --tag=CXX    --mode=compile CC -DHAVE_CONFIG_H  -I../include -I../include -I/usr/include/pgsql     -g -c -o connection_base.lo connection_base.cxx
libtool: compile:  CC -DHAVE_CONFIG_H -I../include -I../include -I/usr/include/pgsql -g -c connection_base.cxx  -KPIC -DPIC -o .libs/connection_base.o
"connection_base.cxx", line 480: Error: Cannot use std::__reverse_bi_iterator<std::list<pqxx::errorhandler*>::iterator, std::bidirectional_iterator_tag, pqxx::errorhandler*, pqxx::errorhandler*&, pqxx::errorhandler**, int> to initialize const std::__reverse_bi_iterator<std::list<pqxx::errorhandler*>::const_iterator, std::bidirectional_iterator_tag, pqxx::errorhandler*, pqxx::errorhandler*const&, pqxx::errorhandler*const*, int>.
"connection_base.cxx", line 481: Error: Cannot use std::__reverse_bi_iterator<std::list<pqxx::errorhandler*>::iterator, std::bidirectional_iterator_tag, pqxx::errorhandler*, pqxx::errorhandler*&, pqxx::errorhandler**, int> to initialize const std::__reverse_bi_iterator<std::list<pqxx::errorhandler*>::const_iterator, std::bidirectional_iterator_tag, pqxx::errorhandler*, pqxx::errorhandler*const&, pqxx::errorhandler*const*, int>.
"connection_base.cxx", line 1001: Error: Cannot use std::__reverse_bi_iterator<std::list<pqxx::errorhandler*>::iterator, std::bidirectional_iterator_tag, pqxx::errorhandler*, pqxx::errorhandler*&, pqxx::errorhandler**, int> to initialize const std::__reverse_bi_iterator<std::list<pqxx::errorhandler*>::const_iterator, std::bidirectional_iterator_tag, pqxx::errorhandler*, pqxx::errorhandler*const&, pqxx::errorhandler*const*, int>.
"connection_base.cxx", line 1002: Error: Cannot use std::__reverse_bi_iterator<std::list<pqxx::errorhandler*>::iterator, std::bidirectional_iterator_tag, pqxx::errorhandler*, pqxx::errorhandler*&, pqxx::errorhandler**, int> to initialize const std::__reverse_bi_iterator<std::list<pqxx::errorhandler*>::const_iterator, std::bidirectional_iterator_tag, pqxx::errorhandler*, pqxx::errorhandler*const&, pqxx::errorhandler*const*, int>.
4 Error(s) detected.
*** Error code 1
dmake: Fatal error: Command failed for target `connection_base.lo'
Current working directory /var/tmp/build/libpqxx-4.0.1/src
Waiting for 1 job to finish
develop --> Job output
source='binarystring.cxx' object='binarystring.lo' libtool=yes \
DEPDIR=.deps depmode=none /bin/bash ../config/depcomp \
/bin/bash ../libtool --tag=CXX    --mode=compile CC -DHAVE_CONFIG_H  -I../include -I../include -I/usr/include/pgsql     -g -c -o binarystring.lo binarystring.cxx
libtool: compile:  CC -DHAVE_CONFIG_H -I../include -I../include -I/usr/include/pgsql -g -c binarystring.cxx  -KPIC -DPIC -o .libs/binarystring.o
libtool: compile:  CC -DHAVE_CONFIG_H -I../include -I../include -I/usr/include/pgsql -g -c binarystring.cxx -o binarystring.o >/dev/null 2>&1
*** Error code 1
The following command caused the error:
fail= failcom='exit 1'; \
for f in x $MAKEFLAGS; do \
  case $f in \
    *=* | --[!k]*);; \
    *k*) failcom='fail=yes';; \
  esac; \
done; \
dot_seen=no; \
target=`echo all-recursive | sed s/-recursive//`; \
list='include src test tools win32 config debian doc'; for subdir in $list; do \
  echo "Making $target in $subdir"; \
  if test "$subdir" = "."; then \
    dot_seen=yes; \
    local_target="$target-am"; \
  else \
    local_target="$target"; \
  fi; \
  (CDPATH="${ZSH_VERSION+.}:" && cd $subdir && dmake  $local_target) \
  || eval $failcom; \
done; \
if test "$dot_seen" = "no"; then \
  dmake  "$target-am" || exit 1; \
fi; test -z "$fail"
dmake: Fatal error: Command failed for target `all-recursive'

Additional information

-bash-3.2$ cat /etc/release

                      Solaris 10 10/09 s10x_u8wos_08a X86
          Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                          Assembled 16 September 2009

-bash-3.2$ /usr/bin/version

Solaris Studio version tool
Usage: version <file> ...        # show version string in one or more binaries
      version -p <command> ...  # look command(s) on PATH and show version
To see a list of the Studio components installed on your system, use
the package command that is appropriate for your system.
To see which package contains the cc binary use commands like this:
  On Solaris 10 : pkgchk -l -p /path/to/.../bin/cc
  On Solaris 11 : pkg search -lp /path/to/.../bin/cc
  On Linux      : rpm -qf /path/to/.../bin/cc
To see which Studio packages are installed on the system:
  On Solaris 10 : pkginfo | grep SPRO
  On Solaris 11 : pkg list | grep -i studio
  On Linux      : rpm -qa | grep solstudio | head

-bash-3.2$ pkgchk -l -p /usr/bin/CC

-bash: pkgchk: command not found

-bash-3.2$ pkginfo | grep SPRO

application SPRO-12-3-analyzer               Performance Analyzer (including collect, analyzer, er_print, ...)
application SPRO-12-3-backend                Compiler Common Files
application SPRO-12-3-c++                    C++ Compilers
application SPRO-12-3-c++-libs               C++ dynamic libraries
application SPRO-12-3-cc                     C Compiler
application SPRO-12-3-code-analyzer          Oracle Solaris Studio Code Analyzer Tool
application SPRO-12-3-dbx                    Dbx Debugging Tools
application SPRO-12-3-dbxtool                Dbxtool standalone debugger GUI
application SPRO-12-3-dlight                 DLight Observability Tool
application SPRO-12-3-dmake                  Building Software including Distributed Make (dmake)
application SPRO-12-3-f90-libs               Fortran dynamic libraries
application SPRO-12-3-fortran                Fortran Compiler
application SPRO-12-3-math-libs              math libraries
application SPRO-12-3-oic                    Oracle Instant Client 11.2.0.2.0
application SPRO-12-3-oic-libs               Oracle Instant Client 11.2.0.2.0 Runtime
application SPRO-12-3-perflib                Performance Library
application SPRO-12-3-studio-bin-links       Oracle Solaris Studio /usr symlinks and icon
application SPRO-12-3-studio-common          Common internal components needed by components of the Oracle Solaris Studio product
application SPRO-12-3-studio-ide             Integrated Development Environment for C, C++, and Fortran
application SPRO-12-3-studio-ja              Solaris Studio Japanese localization
application SPRO-12-3-studio-legal           Legal files for the Solaris Studio product
application SPRO-12-3-studio-zhCN            Solaris Studio Simplified Chinese localization

Solution

  • How I got libpqxx to build

    Clean mess from previous attempt

    rm -rf install_test/

    rm -rf libpqxx-4.0.1/

    Logged out, logged in, set $PATH.

    export PATH=/usr/bin:/usr/ccs/bin

    Create install test dir, extract libpqxx tarball, go into extracted dir

    mkdir install_test/

    /usr/sfw/bin/gtar xf libpqxx-4.0.1.tar.gz

    cd libpqxx-4.0.1/

    Apply patches

    Mine

    cat ../splitconfig.diff

    1c1
    < #! /usr/bin/python
    ---
    > #! /opt/csw/bin/python2.7
    

    patch -i ../splitconfig.diff tools/splitconfig

      Looks like a normal diff.
    done
    

    Patches from OpenCSW

    These two patches were written for the development version of libpqxx but they apply cleanly to libpqxx-4.0.1 using gpatch (installed from OpenCSW). The patches were found at https://buildfarm.opencsw.org/source/xref/opencsw/csw/mgar/pkg/libpqxx/trunk/files/0001-Can-t-instantiate-a-const-iterator-from-non-const.patch and https://buildfarm.opencsw.org/source/xref/opencsw/csw/mgar/pkg/libpqxx/trunk/files/0002-Don-t-test-for-reverse-iters-if-they-re-not-there.patch via https://buildfarm.opencsw.org/source/xref/opencsw/csw/mgar/pkg/libpqxx/trunk/Makefile via http://www.opencsw.org/package/libpqxx5_0/ (link called "OpenGrok"). Both of the patches I used were from revision 17955 of OpenCSW.

    /opt/csw/bin/gpatch src/connection_base.cxx ../0001-Can-t-instantiate-a-const-iterator-from-non-const.patch

    patching file src/connection_base.cxx
    Hunk #1 succeeded at 476 with fuzz 1.
    Hunk #2 succeeded at 997 (offset -2 lines).
    

    /opt/csw/bin/gpatch test/unit/test_binarystring.cxx ../0002-Don-t-test-for-reverse-iters-if-they-re-not-there.patch

    patching file test/unit/test_binarystring.cxx
    

    Configure and make, make install

    CXXFLAGS="-library=stlport4" ./configure --prefix=/var/tmp/build/install_test --enable-shared=yes --enable-static=no --enable-documentation=yes

    make

    make install

    (The documentation, for some reason, is built but not installed. That's just a minor problem, though.)