The c ++ interface of ipvs has long been changed to libpqxx. libpq ++ cannot be compiled and passed in Ubuntu14.04. Some changes need to be made to use libpq ++. Download libpq1_0000-4.0.tar.gz and decompress it ------------------------------------------ split line -------------------------------------------- free on
The c ++ interface of ipvs has long been changed to libpqxx. libpq ++ cannot be compiled in Ubuntu 14.04. Some modifications are required to use libpq ++.
Download libpq1_0000-4.0.tar.gz and decompress it.
------------------------------------------ Split line ------------------------------------------
Free onHttp://linux.linuxidc.com/
Both the user name and password areWww.linuxidc.com
The specific download directory is in/October 14.04/October 13/October 13/Ubuntu use libpq ++/
Download Method see http://www.linuxidc.com/Linux/2013-07/87684.htm
------------------------------------------ Split line ------------------------------------------
2. Go to the libpq ++-4.0 directory
3. Open Makefile
Modify POSTGRES_HOME =/opt/PostgreSQL/9.3 (your postgresql installation directory)
Modify CXXOPTS =-fPIC-DHAVE_NAMESPACE_STD-DHAVE_CXX_STRING_HEADER-DDLLIMPORT = ""
-FPIC must be added to 64-bit Systems
4. Open pgdatabase. cc
Include the stdlib. h file name at the beginning (otherwise the atoi function cannot be found)
V. make & sudo make install
6. Add/etc/ld. so. conf. d/or LD_LIBRARY_PATH to the library search path.
Run sudo ldconfig-v
Or add-Wl,-rpath =/opt/PostgreSQL/9.3/lib during compilation.
VII. Test
Test. cpp (modify mydb and mytable)
# Include
# Include
# Include
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" < Exit (1 );
}
If (! Data. ExecTuplesOk (query_string )){
Cout <"Query Failed! "<Endl;
Exit (1 );
}
For (int k = 0; k
Cout < Cout <"";
}
Cout < For (int I = 0; I <data. Tuples (); I ++ ){
For (int k = 0; k
Cout <data. GetValue (I, k );
Cout <"| ";
}
Cout < }
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
For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2
This article permanently updates the link address: Http://www.linuxidc.com/Linux/2015-12/126168.htm