当前位置: 首页 > news >正文

ubuntu下编译libpq和libpqxx库

ubuntu下编译libpq和libpqxx库,用于链接人大金仓

上篇文章验证了libpqxx可以链接人大金仓数据库,这篇文章尝试自己编译libpq和libpqxx库。

文章目录

  • ubuntu下编译libpq和libpqxx库,用于链接人大金仓
    • libpq
      • 下载libpq库
      • 看看有没有libpq库
      • 编译libpq
      • readline问题
      • 编译postgresql
      • 尝试单独编译libpq库
    • libpqxx
      • 下载libpqxx
      • 选版本
      • configure --help
      • 编译配置
      • 编译
      • 再编译
      • 再再编译
      • 看看依赖
    • 好像没有问题,收工

libpq

下载libpq库

找了以打晌儿,就是找不到,咋办?放弃吧,等等,好像在postgresql源码中。

下载源码看看有没有。

官网走起:https://www.postgresql.org/

两会期间,网速贼慢,物理吐槽,等版半天打开了一次,就不知道怎么遭到下载地址了。

先按照ubuntu18源中的版本进行下载。

$ dpkg -L libpq-dev | grep -F ".pc" | xargs cat
Name: libpq
Description: PostgreSQL libpq library
Url: http://www.postgresql.org/
Version: 10.23
Requires: 
Requires.private: 
Cflags: -I/usr/include/postgresql
Libs: -L/usr/lib/x86_64-linux-gnu -lpq
Libs.private: -L/usr/lib/x86_64-linux-gnu/mit-krb5 -lssl -lcrypto -lgssapi_krb5 -lcrypt -lldap_r

最终的下载位置为:https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.gz
需要其他版本呢自己找,自己在官网找好了。

看看有没有libpq库

解压后,搜一下libpq关键字

# root @ ubuntu in ~/workspace/postgresql-10.23 [8:10:53] 
$ find . -name "*libpq*"
./src/backend/libpq
./src/backend/replication/libpqwalreceiver
./src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
./src/interfaces/libpq
./src/interfaces/libpq/libpq-fe.h
./src/interfaces/libpq/libpq-int.h
./src/interfaces/libpq/libpq.rc.in
./src/interfaces/libpq/libpq-events.h
./src/interfaces/libpq/libpq-events.c
./src/interfaces/libpq/libpqddll.def
./src/interfaces/libpq/libpqdll.def
./src/interfaces/libpq/libpq-dist.rc
./src/include/libpq
./src/include/libpq/libpq-be.h
./src/include/libpq/libpq.h
./src/include/libpq/libpq-fs.h
./src/bin/pg_rewind/libpq_fetch.c
./src/test/examples/testlibpq3.sql
./src/test/examples/testlibpq2.c
./src/test/examples/testlibpq2.sql
./src/test/examples/testlibpq.c
./src/test/examples/testlibpq4.c
./src/test/examples/testlibpq3.c
./doc/src/sgml/html/libpq-copy.html
./doc/src/sgml/html/libpq-connect.html
./doc/src/sgml/html/libpq.html
./doc/src/sgml/html/libpq-example.html
./doc/src/sgml/html/libpq-fastpath.html
./doc/src/sgml/html/libpq-misc.html
./doc/src/sgml/html/libpq-events.html
./doc/src/sgml/html/libpq-threading.html
./doc/src/sgml/html/libpq-pgpass.html
./doc/src/sgml/html/libpq-status.html
./doc/src/sgml/html/libpq-cancel.html
./doc/src/sgml/html/libpq-ldap.html
./doc/src/sgml/html/libpq-control.html
./doc/src/sgml/html/libpq-build.html
./doc/src/sgml/html/libpq-ssl.html
./doc/src/sgml/html/libpq-envars.html
./doc/src/sgml/html/libpq-async.html
./doc/src/sgml/html/libpq-notify.html
./doc/src/sgml/html/libpq-notice-processing.html
./doc/src/sgml/html/libpq-exec.html
./doc/src/sgml/html/libpq-pgservice.html
./doc/src/sgml/html/libpq-single-row-mode.html
./doc/src/sgml/libpq.sgml

浪费了好大一会儿时间,原来在数据库的源码库中。

编译libpq

怎么单独编译libpq呢。
./configure --help 走起

# root @ ubuntu in ~/workspace/postgresql-10.23 [8:14:49] 
$ ./configure --help
`configure' configures PostgreSQL 10.23 to adapt to many kinds of systems.Usage: ./configure [OPTION]... [VAR=VALUE]...To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.Defaults for the options are specified in brackets.Configuration:-h, --help              display this help and exit--help=short        display options specific to this package--help=recursive    display the short help of all the included packages-V, --version           display version information and exit-q, --quiet, --silent   do not print `checking ...' messages--cache-file=FILE   cache test results in FILE [disabled]-C, --config-cache      alias for `--cache-file=config.cache'-n, --no-create         do not create output files--srcdir=DIR        find the sources in DIR [configure dir or `..']Installation directories:--prefix=PREFIX         install architecture-independent files in PREFIX[/usr/local/pgsql]--exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX[PREFIX]By default, `make install' will install all the files in
`/usr/local/pgsql/bin', `/usr/local/pgsql/lib' etc.  You can specify
an installation prefix other than `/usr/local/pgsql' using `--prefix',
for instance `--prefix=$HOME'.For better control, use the options below.Fine tuning of the installation directories:--bindir=DIR            user executables [EPREFIX/bin]--sbindir=DIR           system admin executables [EPREFIX/sbin]--libexecdir=DIR        program executables [EPREFIX/libexec]--sysconfdir=DIR        read-only single-machine data [PREFIX/etc]--sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]--localstatedir=DIR     modifiable single-machine data [PREFIX/var]--libdir=DIR            object code libraries [EPREFIX/lib]--includedir=DIR        C header files [PREFIX/include]--oldincludedir=DIR     C header files for non-gcc [/usr/include]--datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]--datadir=DIR           read-only architecture-independent data [DATAROOTDIR]--infodir=DIR           info documentation [DATAROOTDIR/info]--localedir=DIR         locale-dependent data [DATAROOTDIR/locale]--mandir=DIR            man documentation [DATAROOTDIR/man]--docdir=DIR            documentation root [DATAROOTDIR/doc/postgresql]--htmldir=DIR           html documentation [DOCDIR]--dvidir=DIR            dvi documentation [DOCDIR]--pdfdir=DIR            pdf documentation [DOCDIR]--psdir=DIR             ps documentation [DOCDIR]System types:--build=BUILD     configure for building on BUILD [guessed]--host=HOST       cross-compile to build programs to run on HOST [BUILD]Optional Features:--disable-option-checking  ignore unrecognized --enable/--with options--disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)--enable-FEATURE[=ARG]  include FEATURE [ARG=yes]--disable-integer-datetimesobsolete option, no longer supported--enable-nls[=LANGUAGES]enable Native Language Support--disable-rpath         do not embed shared library search path inexecutables--disable-spinlocks     do not use spinlocks--disable-atomics       do not use atomic operations--disable-strong-random do not use a strong random number source--enable-debug          build with debugging symbols (-g)--enable-profiling      build with profiling enabled--enable-coverage       build with coverage testing instrumentation--enable-dtrace         build with DTrace support--enable-tap-tests      enable TAP tests (requires Perl and IPC::Run)--enable-depend         turn on automatic dependency tracking--enable-cassert        enable assertion checks (for debugging)--disable-thread-safety disable thread-safety in client libraries--disable-largefile     omit support for large files--disable-float4-byval  disable float4 passed by value--disable-float8-byval  disable float8 passed by valueOptional Packages:--with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]--without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)--with-extra-version=STRINGappend STRING to version--with-template=NAME    override operating system template--with-includes=DIRS    look for additional header files in DIRS--with-libraries=DIRS   look for additional libraries in DIRS--with-libs=DIRS        alternative spelling of --with-libraries--with-pgport=PORTNUM   set default port number [5432]--with-blocksize=BLOCKSIZEset table block size in kB [8]--with-segsize=SEGSIZE  set table segment size in GB [1]--with-wal-blocksize=BLOCKSIZEset WAL block size in kB [8]--with-wal-segsize=SEGSIZEset WAL segment size in MB [16]--with-CC=CMD           set compiler (deprecated)--with-icu              build with ICU support--with-tcl              build Tcl modules (PL/Tcl)--with-tclconfig=DIR    tclConfig.sh is in DIR--with-perl             build Perl modules (PL/Perl)--with-python           build Python modules (PL/Python)--with-gssapi           build with GSSAPI support--with-krb-srvnam=NAME  default service principal name in Kerberos (GSSAPI)[postgres]--with-pam              build with PAM support--with-bsd-auth         build with BSD Authentication support--with-ldap             build with LDAP support--with-bonjour          build with Bonjour support--with-openssl          build with OpenSSL support--with-selinux          build with SELinux support--with-systemd          build with systemd support--without-readline      do not use GNU Readline nor BSD Libedit for editing--with-libedit-preferredprefer BSD Libedit over GNU Readline--with-uuid=LIB         build contrib/uuid-ossp using LIB (bsd,e2fs,ossp)--with-ossp-uuid        obsolete spelling of --with-uuid=ossp--with-libxml           build with XML support--with-libxslt          use XSLT support when building contrib/xml2--with-system-tzdata=DIRuse system time zone data in DIR--without-zlib          do not use Zlib--with-gnu-ld           assume the C compiler uses GNU ld [default=no]Some influential environment variables:CC          C compiler commandCFLAGS      C compiler flagsLDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in anonstandard directory <lib dir>LIBS        libraries to pass to the linker, e.g. -l<library>CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> ifyou have headers in a nonstandard directory <include dir>CPP         C preprocessorPKG_CONFIG  path to pkg-config utilityPKG_CONFIG_PATHdirectories to add to pkg-config's search pathPKG_CONFIG_LIBDIRpath overriding pkg-config's built-in search pathICU_CFLAGS  C compiler flags for ICU, overriding pkg-configICU_LIBS    linker flags for ICU, overriding pkg-configXML2_CONFIG path to xml2-config utilityXML2_CFLAGS C compiler flags for XML2, overriding pkg-configXML2_LIBS   linker flags for XML2, overriding pkg-configLDFLAGS_EX  extra linker flags for linking executables onlyLDFLAGS_SL  extra linker flags for linking shared libraries onlyUse these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.Report bugs to <pgsql-bugs@postgresql.org>.

嗨~,看的头痛,完整编译以便。

./configure --prefix=/opt/postgresql

checking for library containing readline... no
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.

报错,没有readline

readline问题

请教一下apt老师

$ apt install postgresql
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:libsecret-1-0 libsecret-common python-asn1crypto python-backports.ssl-match-hostname python-cached-property python-certifi python-cffi-backend python-chardetpython-cryptography python-dockerpty python-docopt python-enum34 python-funcsigs python-functools32 python-idna python-ipaddress python-jsonschema python-mock python-opensslpython-pbr python-pkg-resources python-requests python-six python-texttable python-urllib3 python-websocket python-yaml
Use 'apt autoremove' to remove them.
The following additional packages will be installed:postgresql-10 postgresql-client-10 postgresql-client-common postgresql-common ssl-cert sysstat
Suggested packages:postgresql-doc locales-all postgresql-doc-10 libjson-perl openssl-blacklist isag
The following NEW packages will be installed:postgresql postgresql-10 postgresql-client-10 postgresql-client-common postgresql-common ssl-cert sysstat
0 upgraded, 7 newly installed, 0 to remove and 86 not upgraded.
Need to get 5,227 kB of archives.
After this operation, 20.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.

没有看到有readline相关依赖,跳过把,不管了。
./configure --prefix=/opt/postgresql --without-readline

configure: using compiler=gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -O2
configure: using CPPFLAGS= -D_GNU_SOURCE 
configure: using LDFLAGS=  -Wl,--as-needed
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating src/Makefile.global
config.status: creating src/include/pg_config.h
config.status: creating src/include/pg_config_ext.h
config.status: creating src/interfaces/ecpg/include/ecpg_config.h
config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking src/backend/port/dynloader/linux.c to src/backend/port/dynloader.c
config.status: linking src/backend/port/posix_sema.c to src/backend/port/pg_sema.c
config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking src/backend/port/dynloader/linux.h to src/include/dynloader.h
config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
config.status: linking src/makefiles/Makefile.linux to src/Makefile.port

好像没有报错,开始编译

编译postgresql

make && make install
漫长的等待,终于编译好了,但是东西有点多,怎么分离出来有用的文件呢?

继续请教apt老师。

相关的头文件

$ dpkg -L libpq-dev | grep -F "/usr/include/postgresql"
/usr/include/postgresql
/usr/include/postgresql/internal
/usr/include/postgresql/internal/c.h
/usr/include/postgresql/internal/libpq
/usr/include/postgresql/internal/libpq/pqcomm.h
/usr/include/postgresql/internal/libpq-int.h
/usr/include/postgresql/internal/port.h
/usr/include/postgresql/internal/postgres_fe.h
/usr/include/postgresql/internal/pqexpbuffer.h
/usr/include/postgresql/libpq
/usr/include/postgresql/libpq/libpq-fs.h
/usr/include/postgresql/libpq-events.h
/usr/include/postgresql/libpq-fe.h
/usr/include/postgresql/pg_config.h
/usr/include/postgresql/pg_config_ext.h
/usr/include/postgresql/pg_config_manual.h
/usr/include/postgresql/pg_config_os.h
/usr/include/postgresql/postgres_ext.h

相关的库文件

$ dpkg -L libpq-dev | grep -F "/usr/lib/x86_64-linux-gnu"
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libpgcommon.a
/usr/lib/x86_64-linux-gnu/libpgfeutils.a
/usr/lib/x86_64-linux-gnu/libpgport.a
/usr/lib/x86_64-linux-gnu/libpq.a
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/libpq.pc
/usr/lib/x86_64-linux-gnu/libpq.so

库还好,可以分离出来,但是头文件有些麻烦,如果编译其他版本,头文件目录不一致,也是问题。

尝试单独编译libpq库

人家就是不支持,非得单独编译,嗨

头文件直接不分离,实在不行,开发时把真个头文件目录整个拷贝过去,多了也没有关系。

libpqxx

下载libpqxx

找到libpqxx与libpq的版本对应关系,
还是按照apt的版本对应关系。

$ dpkg -L libpqxx-dev | grep -F ".pc" | xargs cat        
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/x86_64-linux-gnu
includedir=${prefix}/includeName: libpqxx
Description: a C++ API to the PostgreSQL database management system.
Version: 4.0.1
Libs: -L${libdir} -L/usr/lib/x86_64-linux-gnu -lpqxx
Cflags: -I${includedir} -I/usr/include/postgresql

github源码地址:https://github.com/jtv/libpqxx

然并卵,libpqxx都没有这个4.01版本了,咋办。

选版本

libpqxx 从7.0.0版本,开始要求基于C++17,我这个的开发环境还是C++11
所以就用libpqxx的6.x.x的最后一个版本6.4.8好了。

https://github.com/jtv/libpqxx/archive/refs/tags/6.4.8.tar.gz

configure --help

# root @ ubuntu in ~/workspace/libpqxx-6.4.8 [9:19:51] 
$ ./configure --help
`configure' configures libpqxx 6.4.8 to adapt to many kinds of systems.Usage: ./configure [OPTION]... [VAR=VALUE]...To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.Defaults for the options are specified in brackets.Configuration:-h, --help              display this help and exit--help=short        display options specific to this package--help=recursive    display the short help of all the included packages-V, --version           display version information and exit-q, --quiet, --silent   do not print `checking ...' messages--cache-file=FILE   cache test results in FILE [disabled]-C, --config-cache      alias for `--cache-file=config.cache'-n, --no-create         do not create output files--srcdir=DIR        find the sources in DIR [configure dir or `..']Installation directories:--prefix=PREFIX         install architecture-independent files in PREFIX[/usr/local]--exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX[PREFIX]By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.For better control, use the options below.Fine tuning of the installation directories:--bindir=DIR            user executables [EPREFIX/bin]--sbindir=DIR           system admin executables [EPREFIX/sbin]--libexecdir=DIR        program executables [EPREFIX/libexec]--sysconfdir=DIR        read-only single-machine data [PREFIX/etc]--sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]--localstatedir=DIR     modifiable single-machine data [PREFIX/var]--runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]--libdir=DIR            object code libraries [EPREFIX/lib]--includedir=DIR        C header files [PREFIX/include]--oldincludedir=DIR     C header files for non-gcc [/usr/include]--datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]--datadir=DIR           read-only architecture-independent data [DATAROOTDIR]--infodir=DIR           info documentation [DATAROOTDIR/info]--localedir=DIR         locale-dependent data [DATAROOTDIR/locale]--mandir=DIR            man documentation [DATAROOTDIR/man]--docdir=DIR            documentation root [DATAROOTDIR/doc/libpqxx]--htmldir=DIR           html documentation [DOCDIR]--dvidir=DIR            dvi documentation [DOCDIR]--pdfdir=DIR            pdf documentation [DOCDIR]--psdir=DIR             ps documentation [DOCDIR]Program names:--program-prefix=PREFIX            prepend PREFIX to installed program names--program-suffix=SUFFIX            append SUFFIX to installed program names--program-transform-name=PROGRAM   run sed PROGRAM on installed program namesSystem types:--build=BUILD     configure for building on BUILD [guessed]--host=HOST       cross-compile to build programs to run on HOST [BUILD]Optional Features:--disable-option-checking  ignore unrecognized --enable/--with options--disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)--enable-FEATURE[=ARG]  include FEATURE [ARG=yes]--enable-dependency-trackingdo not reject slow dependency extractors--disable-dependency-trackingspeeds up one-time build--enable-silent-rules   less verbose build output (undo: "make V=1")--disable-silent-rules  verbose build output (undo: "make V=0")--enable-shared[=PKGS]  build shared libraries [default=no]--enable-static[=PKGS]  build static libraries [default=yes]--enable-fast-install[=PKGS]optimize for fast installation [default=yes]--disable-libtool-lock  avoid locking (might break parallel builds)--enable-documentation  Generate documentation--enable-maintainer-modeenable make rules and dependencies not useful (andsometimes confusing) to the casual installer--enable-poll           System supports poll().Optional Packages:--with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]--without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)--with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=useboth]--with-aix-soname=aix|svr4|bothshared library versioning (aka "SONAME") variant toprovide on AIX, [default=aix].--with-gnu-ld           assume the C compiler uses GNU ld [default=no]--with-sysroot[=DIR]    Search for dependent libraries within DIR (or thecompiler's sysroot if not specified).--with-postgres-include=DIRUse PostgreSQL includes from DIR. Defaults toquerying pg_config or pkg-config, whichever isavailable.--with-postgres-lib=DIR Use PostgreSQL libraries from DIR. Defaults toquerying pg_config.Some influential environment variables:CXX         C++ compiler commandCXXFLAGS    C++ compiler flagsLDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in anonstandard directory <lib dir>LIBS        libraries to pass to the linker, e.g. -l<library>CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> ifyou have headers in a nonstandard directory <include dir>CC          C compiler commandCFLAGS      C compiler flagsLT_SYS_LIBRARY_PATHUser-defined run-time library search path.CPP         C preprocessorCXXCPP      C++ preprocessorDOXYGEN     Path to doxygen needed to build reference documentationHAVE_DOT    Variable used by doxygen to declare availibility of dotXMLTO       Path to xmlto needed to build tutorial documentationUse these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.Report bugs to <Jeroen T. Vermeulen>.

编译配置

./configure --prefix=/opt/libpqxx --with-postgres-include=/opt/postgresql/include --with-postgres-lib=/opt/postgresql/lib

$ ./configure  --prefix=/opt/libpqxx  --with-postgres-include=/opt/postgresql/include --with-postgres-lib=/opt/postgresql/lib
checking for g++... g++
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... yes
checking whether g++ accepts -g... yes
checking whether g++ supports C++11 features with -std=c++11... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports the include directive... yes (GNU style)
checking whether make supports nested variables... yes
checking dependency style of g++ -std=c++11... gcc3
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ -std=c++11 accepts -g... (cached) yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
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... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -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 if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -std=c++11 -E
checking for ld used by g++ -std=c++11... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ -std=c++11 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ -std=c++11 option to produce PIC... -fPIC -DPIC
checking if g++ -std=c++11 PIC flag -fPIC -DPIC works... yes
checking if g++ -std=c++11 static flag -static works... yes
checking if g++ -std=c++11 supports -c -o file.o... yes
checking if g++ -std=c++11 supports -c -o file.o... (cached) yes
checking whether the g++ -std=c++11 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether make sets $(MAKE)... (cached) yes
checking for mkdir... /bin/mkdir
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 audit... 
checking g++ visibility attribute... yes
checking whether the compiler supports function __attribute__((__const__))... yes
checking g++ deprecation attribute... yes
checking g++ pure attribute... yes
checking C++14 deprecation attribute... yes
checking for C++17 std::optional support... no
checking for experimental C++17 std::optional support... no
checking for C++17 charconv integer conversion... no
checking for C++17 charconv floating-point conversion... no
checking for poll(2)... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for pg_config... /usr/bin/pg_config
checking for pkg-config... /usr/bin/pkg-config
configure: using PostgreSQL headers at /opt/postgresql/include
configure: using PostgreSQL libraries at /opt/postgresql/lib
checking /opt/postgresql/include/libpq-fe.h usability... yes
checking /opt/postgresql/include/libpq-fe.h presence... yes
checking for /opt/postgresql/include/libpq-fe.h... yes
checking for ability to compile source files using libpq... yes
checking for PQexec in -lpq... yes
checking that type of libpq's Oid is as expected... yes
checking whether make sets $(MAKE)... (cached) yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config/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 include/pqxx/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing configitems commands
Generating b'/root/workspace/libpqxx-6.4.8/include/pqxx/config-internal-autotools.h': 7 item(s).
Generating b'/root/workspace/libpqxx-6.4.8/include/pqxx/config-internal-compiler.h': 5 item(s).
Generating b'/root/workspace/libpqxx-6.4.8/include/pqxx/config-public-autotools.h': no items--skipping.
Generating b'/root/workspace/libpqxx-6.4.8/include/pqxx/config-public-compiler.h': 4 item(s).

好像没有问题,

编译

make && make install

报错

*****************************************************xmlto not found.
Install it, or configure with --disable-documentation*****************************************************
Makefile:508: recipe for target 'tutorial-stamp' failed
make[1]: *** [tutorial-stamp] Error 1
make[1]: Leaving directory '/root/workspace/libpqxx-6.4.8/doc'
Makefile:641: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

CNM,configure时不报错,非得在编译时报错。

再编译

./configure --prefix=/opt/libpqxx --with-postgres-include=/opt/postgresql/include --with-postgres-lib=/opt/postgresql/lib --disable-documentation
make && make install

# root @ ubuntu in /opt/libpqxx [9:32:58] 
$ tree -L 2
.
├── include
│   └── pqxx
└── lib├── libpqxx.a├── libpqxx.la└── pkgconfig

操了,没有动态库。make clean再来。

再再编译

make clean
./configure --prefix=/opt/libpqxx --with-postgres-include=/opt/postgresql/include --with-postgres-lib=/opt/postgresql/lib --disable-documentation --enable-shared=yes
make && make install

# root @ ubuntu in /opt/libpqxx [10:15:59] 
$ tree -L 2
.
├── include
│   └── pqxx
└── lib├── libpqxx-6.4.so├── libpqxx.a├── libpqxx.la├── libpqxx.so -> libpqxx-6.4.so└── pkgconfig

看看依赖

先配置一下环境变量
export LD_LIBRARY_PATH=/opt/postgresql/lib;$LD_LIBRARY_PATH

# root @ ubuntu in /opt/libpqxx/lib [10:22:26] 
$ ldd libpqxx.so linux-vdso.so.1 (0x00007ffea9739000)libpq.so.5 => /opt/postgresql/lib/libpq.so.5 (0x00007f2579620000)libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f2579297000)libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2578ea6000)/lib64/ld-linux-x86-64.so.2 (0x00007f2579acf000)libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f2578c8e000)libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2578a6f000)libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f25786d1000)

好像没有问题,收工

相关文章:

ubuntu下编译libpq和libpqxx库

ubuntu下编译libpq和libpqxx库&#xff0c;用于链接人大金仓 上篇文章验证了libpqxx可以链接人大金仓数据库&#xff0c;这篇文章尝试自己编译libpq和libpqxx库。 文章目录ubuntu下编译libpq和libpqxx库&#xff0c;用于链接人大金仓libpq下载libpq库看看有没有libpq库编译lib…...

ESP-C2系列模组开发板简介

C2是一个芯片采用4毫米x 4毫米封装&#xff0c;与272 kB内存。它运行框架&#xff0c;例如ESP-Jumpstart和ESP造雨者&#xff0c;同时它也运行ESP-IDF。ESP-IDF是Espressif面向嵌入式物联网设备的开源实时操作系统&#xff0c;受到了全球用户的信赖。它由支持Espressif以及所有…...

linux权限管理

权限管理 文件的权限针对三类对象进行定义&#xff1a; owner属主&#xff0c;缩写ugroup属组&#xff0c;缩写gother其他&#xff0c;缩写o 1、文件的一般权限 &#xff08;1&#xff09;r,w,x的作用及含义&#xff1a; 权限对文件影响对目录影响r&#xff08;read&#xf…...

提高生活质量,增加学生对校园服务的需求,你知道有哪些?

随着电子商务平台利用移动互联网的趋势提高服务质量&#xff0c;越来越多的传统企业开始关注年轻大学生消费者的校园市场。 提高生活质量&#xff0c;增加学生对校园服务的需求 大学生越来越沉迷于用手机解决生活中的“吃、喝、玩、乐”等服务&#xff0c;如“吃、喝”——可…...

Antlr4:使用grun命令,触发NoClassDefFoundError

1. 意外的发现 在学习使用grun命令时&#xff0c;从未遇到过错误 最近使用grun命令&#xff0c;却遇到了NoClassDefFoundError的错误&#xff0c;使得grun测试工具无法成功启动 错误复现&#xff1a; 使用antlr4命令编译Hello.g4文件&#xff0c;并为指定package&#xff08;…...

基于rootfs构建Docker镜像

1. 背景 在实际工作中&#xff0c;由于系统本身版本过低&#xff0c;在接受新项目时出现系统版本过低而无法开始工作的问题。 为了解决该问题&#xff0c;使用Docker构建基于ubuntu-18.04的Docker镜像&#xff0c;以解决版本兼容问题。 2. 构建rootfs 2.1. 下载ubuntu-18.0…...

电脑文件软件搬家迁移十大工具

10 大适用于 Windows 的数据迁移软件。 数据迁移至关重要&#xff0c;几乎所有组织都依赖于此。如果您认为数据传输不是一件容易的事&#xff0c;那么数据迁移软件可以帮上忙。 1、奇客电脑迁移 将现有操作系统、软件、文件迁移到 新电脑的最佳方法之一是使用名为奇客电脑迁移…...

【数据库】排名问题

返回第N高的一个解决思路返回N组中的第N高解决思路分数排名解决思路窗口函数数据库经常被用来解决排名问题。 返回第N高的一个 单表查询: 表: Employee------------------- | Column Name | Type | ------------------- | id | int | | salary | int | ----…...

【redis学习篇】主从哨兵集群架构详解

一、Redis主从架构 1.1 redis主从架构搭建 1、复制一份redis.conf文件 2、将相关配置修改为如下值&#xff1a; port 6380 pidfile /var/run/redis_6380.pid # 把pid进程号写入pidfile配置的文件 logfile "6380.log" dir /usr/local/redis-5.0.3/data/6380 # 指…...

基于jdk8的HashMap源码解析

hashMap常见面试题总览 为什么重写Equals还要重写HashCode方法&#xff1f;HashMap如何避免内存泄漏问题&#xff1f;HashMap1.7底层是如何实现的&#xff1f;HashMapKey为null存放在什么位置&#xff1f;HashMap如何解决Hash冲突问题&#xff1f;HashMap底层采用单链表还是双…...

深度学习J1周-ResNet50算法实战与解析_鸟类识别(CNN)

&#x1f368; 本文为[&#x1f517;365天深度学习训练营]内部限免文章&#xff08;版权归 *K同学啊* 所有&#xff09; &#x1f356; 作者&#xff1a;[K同学啊] 本周任务&#xff1a; ●1.请根据本文 TensorFlow 代码&#xff08;训练营内部阅读&#xff09;&#xff0c;编写…...

SpringBoot中一行代码解决字符串向枚举类型转换的问题

1. 场景 在WEB开发&#xff0c;客户端和服务端传输的数据中经常包含一些这样的字段&#xff1a;字段的值只包括几个固定的字符串。 这样的字段意味着我们需要在数据传输对象&#xff08;Data Transfer Object, DTO&#xff09;中对该字段进行校验以避免客户端传输的非法数据持…...

Praat之基频分析

Praat之基频分析 测量基频F0的方法 自相关 Autocorrelation&#xff08;易出现pitch-halving\pitch-double&#xff09;窄带谱图 Narrowband spectrogram&#xff08;第一谐波就是基频&#xff09;倒谱分析 Cepstral analysis测量声门波 glottal pluse&#xff08;通过波形&a…...

乡村企业门户网站

技术&#xff1a;Java、JSP等摘要&#xff1a;随着时代的发展&#xff0c;电脑与Internet已经进入我们的生活。信息时代的来临&#xff0c;知识经济的扩张&#xff0c;网站已越来越靠近我们的生活。据CNNIC报告显示&#xff0c;中国上网用户有6800万。通过Internet来经营运作一…...

Deploy Workshop|DIY部署环境,让OceanBase跑起来

2023 年 3 月 25 日&#xff0c;我们将在北京开启首次 OceanBase 开发者大会&#xff0c;与开发者共同探讨单机分布式、云原生、HTAP 等数据库前沿趋势&#xff0c;分享全新的产品 Roadmap&#xff0c;交流场景探索和最佳实践&#xff0c;此外&#xff0c;OceanBase 开源技术全…...

【CPP】定义一个类

一&#xff1a;当实现一个类的时候&#xff0c;编译器都做了什么 前言&#xff1a;当我们实现一个类的时候&#xff0c;编译器为我们做了什么&#xff1b;在对类进行操作的时候&#xff0c;有哪些特殊的成员函数可以帮助我们更好的操纵类&#xff1b; class A {A();//默认构造…...

谷歌广告投放步骤流程是什么?一文带你全方位了解实操细节

谷歌&#xff0c;大家都不陌生吧&#xff0c;一个人们很常用的搜索引擎。而谷歌还可以打广告&#xff0c;即谷歌广告&#xff0c;那这跟跨境电商有什么关心呢&#xff1f;东哥告诉大家&#xff0c;关系大了去了&#xff0c;毕竟如果用户搜索与我们相关的关键词&#xff0c;就有…...

TypeScript 怎么去查找类型定义的?

TypeScript 怎么去查找类型定义的&#xff1f;类型文件分类第三方库的类型自定义类型结论类型文件分类 我们项目中的类型文件分为两种&#xff1a;一类是第三方库的类型&#xff0c;一类是在项目中的自定义类型。 第三方库的类型 &#xff08;1&#xff09;Jquery&#xff1…...

NPM包管理器

文章目录一、NPM包管理器1、简介2、安装NPM3、使用npm管理项目3.1项目初始化3.2修改npm镜像3.3 npm install命令的使用3.4其它命令一、NPM包管理器 1、简介 什么是NPM NPM全称Node Package Manager&#xff0c;是Node.js包管理工具&#xff0c;是全球最大的模块生态系统&…...

IT英语记录

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录前言1、Classification2、Logistic Regression3、网络相关3.1 WAN&#xff08;Wide Area Network&#xff09;、LAN&#xff08;Local Area Network&#xff09;网络…...

Prompt Tuning、P-Tuning、Prefix Tuning的区别

一、Prompt Tuning、P-Tuning、Prefix Tuning的区别 1. Prompt Tuning(提示调优) 核心思想:固定预训练模型参数,仅学习额外的连续提示向量(通常是嵌入层的一部分)。实现方式:在输入文本前添加可训练的连续向量(软提示),模型只更新这些提示参数。优势:参数量少(仅提…...

【Java学习笔记】Arrays类

Arrays 类 1. 导入包&#xff1a;import java.util.Arrays 2. 常用方法一览表 方法描述Arrays.toString()返回数组的字符串形式Arrays.sort()排序&#xff08;自然排序和定制排序&#xff09;Arrays.binarySearch()通过二分搜索法进行查找&#xff08;前提&#xff1a;数组是…...

定时器任务——若依源码分析

分析util包下面的工具类schedule utils&#xff1a; ScheduleUtils 是若依中用于与 Quartz 框架交互的工具类&#xff0c;封装了定时任务的 创建、更新、暂停、删除等核心逻辑。 createScheduleJob createScheduleJob 用于将任务注册到 Quartz&#xff0c;先构建任务的 JobD…...

WordPress插件:AI多语言写作与智能配图、免费AI模型、SEO文章生成

厌倦手动写WordPress文章&#xff1f;AI自动生成&#xff0c;效率提升10倍&#xff01; 支持多语言、自动配图、定时发布&#xff0c;让内容创作更轻松&#xff01; AI内容生成 → 不想每天写文章&#xff1f;AI一键生成高质量内容&#xff01;多语言支持 → 跨境电商必备&am…...

Matlab | matlab常用命令总结

常用命令 一、 基础操作与环境二、 矩阵与数组操作(核心)三、 绘图与可视化四、 编程与控制流五、 符号计算 (Symbolic Math Toolbox)六、 文件与数据 I/O七、 常用函数类别重要提示这是一份 MATLAB 常用命令和功能的总结,涵盖了基础操作、矩阵运算、绘图、编程和文件处理等…...

如何在最短时间内提升打ctf(web)的水平?

刚刚刷完2遍 bugku 的 web 题&#xff0c;前来答题。 每个人对刷题理解是不同&#xff0c;有的人是看了writeup就等于刷了&#xff0c;有的人是收藏了writeup就等于刷了&#xff0c;有的人是跟着writeup做了一遍就等于刷了&#xff0c;还有的人是独立思考做了一遍就等于刷了。…...

现有的 Redis 分布式锁库(如 Redisson)提供了哪些便利?

现有的 Redis 分布式锁库&#xff08;如 Redisson&#xff09;相比于开发者自己基于 Redis 命令&#xff08;如 SETNX, EXPIRE, DEL&#xff09;手动实现分布式锁&#xff0c;提供了巨大的便利性和健壮性。主要体现在以下几个方面&#xff1a; 原子性保证 (Atomicity)&#xff…...

2025年渗透测试面试题总结-腾讯[实习]科恩实验室-安全工程师(题目+回答)

安全领域各种资源&#xff0c;学习文档&#xff0c;以及工具分享、前沿信息分享、POC、EXP分享。不定期分享各种好玩的项目及好用的工具&#xff0c;欢迎关注。 目录 腾讯[实习]科恩实验室-安全工程师 一、网络与协议 1. TCP三次握手 2. SYN扫描原理 3. HTTPS证书机制 二…...

uniapp 字符包含的相关方法

在uniapp中&#xff0c;如果你想检查一个字符串是否包含另一个子字符串&#xff0c;你可以使用JavaScript中的includes()方法或者indexOf()方法。这两种方法都可以达到目的&#xff0c;但它们在处理方式和返回值上有所不同。 使用includes()方法 includes()方法用于判断一个字…...

AI语音助手的Python实现

引言 语音助手(如小爱同学、Siri)通过语音识别、自然语言处理(NLP)和语音合成技术,为用户提供直观、高效的交互体验。随着人工智能的普及,Python开发者可以利用开源库和AI模型,快速构建自定义语音助手。本文由浅入深,详细介绍如何使用Python开发AI语音助手,涵盖基础功…...