Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Use libpq under Ubuntu 14.04     - Virtualbox virtual machine can not copy CentOS Network (Linux)

- Redis Linux system installation guide (Database)

- Linux operating system security settings initial understanding (Linux)

- Linux system monitoring, top command of the diagnostic tool Detailed (Linux)

- Java Concurrency: synchronized (Programming)

- Hadoop virtualization performance comparison and tuning experience (Server)

- Ubuntu 14.10 install KDE Plasma 5.2 (Linux)

- Linux install and configure Heartbeat (Server)

- To use Linux to create a secure managed gateway (Linux)

- Linux / BSD firewall M0n0wall Profile (Linux)

- Use libpq under Ubuntu 14.04 (Linux)

- Ubuntu 14.10 splash screen brightness settings (Linux)

- Zabbix monitors Nginx status (Server)

- Linux Tutorial ---- fundamentals of data traffic redirection (Linux)

- Linux NFS FTP use (Server)

- Use Epoll develop high-performance application server on Linux (Server)

- Protect against network attacks using Linux system firewall (Linux)

- To execute the cp command prompt type skip folder under CentOS (Linux)

- Linux port mapping system (routing and forwarding) (Server)

- Linux system security (Linux)

 
         
  Use libpq under Ubuntu 14.04
     
  Add Date : 2018-11-21      
         
       
         
  The Postgres c ++ interfaces already changed libpqxx, libpq ++ in Ubuntu 14.04 can not compile under, in order to use libpq ++ needs some modification.

First, download libpq ++ - 4.0.tar.gz and unzip

Second, enter libpq ++ - 4.0 directory

Third, open the Makefile

Modify POSTGRES_HOME = / opt / PostgreSQL / 9.3 (your postgresql install directory)

Modify CXXOPTS = -fPIC -DHAVE_NAMESPACE_STD -DHAVE_CXX_STRING_HEADER -DDLLIMPORT = ""

64 system must add -fPIC

Fourth, open pgdatabase.cc

Stdlib.h at the top contains the file name (or the atoi function can not find)

Five, make & sudo make install

Six, / etc / ld.so.conf.d / or LD_LIBRARY_PATH plus library search path

And execute sudo ldconfig -v

Or at compile time plus -Wl, -rpath = / opt / PostgreSQL / 9.3 / lib

Seven test

test.cpp (the mydb, mytable tinkering)

#include < stdlib.h>
#include < iostream>
#include < libpq ++. h>
using namespace std;
int main () {
char query_string [256] = "SELECT * FROM mytable;";
PgDatabase data ( "dbname = mydb");
if (data.ConnectionBad ()) {
cout << "connected failed" << endl;
cout << "Error is" << data.ErrorMessage () << endl;
exit (1);
}
if (! data.ExecTuplesOk (query_string)) {
cout << "Query Failed!" << endl;
exit (1);
}
for (int k = 0; k
cout << data.FieldName (k);
cout << "";
}
cout << endl;
for (int i = 0; i for (int k = 0; k
cout << data.GetValue (i, k);
cout << "|";
}
cout << endl;
}
return 0;
}

g ++ test.cpp -o test -fPIC -DHAVE_NAMESPACE_STD -DHAVE_CXX_STRING_HEADER -DDLLIMPORT = "" -I /opt/PostgreSQL/9.3/include -L / opt / PostgreSQL / 9.3 / lib -lpq ++ -lpq
./test
     
         
       
         
  More:      
 
- Ceph distributed storage system is installed on a CentOS 7.1 (Server)
- Linux Getting Started Tutorial: / var / spool / clientmqueue fill the root directory (Linux)
- Python common data type summary (Programming)
- Linux Network Programming - raw socket programming (Programming)
- Setup Qt development environment under Linux (Linux)
- Computer security perimeter recommendations (Linux)
- Linux, Google Test (GTest) test environment to build step (Linux)
- RHEL 6.4 installed MySQL 5.6.27 (Database)
- Ubuntu 14.10 / 14.04 / 12.04 How to install Kodi 14.0 RC3 (Linux)
- Oracle Data Guard LOG_ARCHIVE_DEST_n optional attribute parameters (Database)
- Several Ceph performance optimization of new methods and ideas (2015 SH Ceph Day after flu reference) (Server)
- Ubuntu 12.04 installed OpenCV 2.3.1, binary image (Linux)
- Remote installation of Net-SNMP whole process (Linux)
- php performance monitoring module XHProf (Linux)
- ARP Linux-related operations (Linux)
- Mount and unloading disks under Linux (Linux)
- Linux Firewall IPCop Profile (Linux)
- Linux system security configuration (Linux)
- Examples of RAID levels and achieve Operational Details (Linux)
- Configuration based on open source Lucene Java development environment (Server)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.