pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Linking Errors
2+ messages / 2 participants
[nested] [flat]

* Linking Errors
@ 2000-01-21 15:49 Mike <mfre@telusplanet.net>
  0 siblings, 0 replies; 2+ messages in thread

From: Mike @ 2000-01-21 15:49 UTC (permalink / raw)
  To: pgsql-interfaces

Hello I am having problems linking to the libpq++ libraries.  I tried compiling the the program below that I found in the archive just like
it said 
c++ test3.cpp -o test3 -lpq -lpq++

But I get messages like the following:

/usr/lib/qt/include/qarray.h(.gnu.linkonce.t__tf10PgDatabase+0xd): undefined
reference to 'PgConnection type_info function

Before I had to specify the location of the libpq++.h file until I used
the I switch or else it would say the file was not found.

c++ test3.cpp -o test3 -I/usr/lib/pgsql/include -lpq -lpq++

So I have a couple of questions

1. How do I fix the linking error?
2. When I set the -lpq and -lpq++ I know it is suppose to be including those
libraries but do I need to tell the system where those libraries are? How does
it know?

Please HELP!! :-)
Thanks,
Mike
mfre@telusplanet.net

*************************************************************************************************************************
/* test3.h
joris esch 3.10.1998
*/

#include <libpq++.h>
//#include "/usr/lib/pgsql/include/libpq++.h"     
#include <iostream>
 
//typedef int Error;

/* test3.cpp
joris esch 3.10.1998
*/
// compile with:
// c++ test3.cpp -o test3 -lpq -lpq++

#include "test3.h"

void main()
{
          
  bool verbose = true;
  char* dbname= "template1";        
 

  /* make a connection to the database */
 
  if (verbose) {
    cout << "Trying to connect to db " << dbname  << '\n';;  // << " on host " << pghost;
  } ;
  
  // PgDatabase inherits from PgConnection
  PgDatabase *conn=new PgDatabase(dbname);

  // give error messages if conn is not ok

  if (conn->Status()!=0){
    cerr << "Connection status: " << conn->Status() <<'\n';
    cerr << "Connection failed." << '\n';
    cerr << "Database name: " << conn->DBName() << '\n';
    cerr << conn->ErrorMessage() << '\n';
    //end execution here... or use exception handling...cfr. ch8
    exit(1); //Stroustrup page 116 0== okidoki, 1!=okidoki
    //throw "Connection failed";
  }; 
  
  if (verbose) {cout <<  "Connection succeeded.\n";};
  cout << "You are currently connected to db: " << conn->DBName() << '\n';
  //cout << "Let's do a query";
  //see if i can do  query...
  if (conn->ExecTuplesOk("DECLARE mycursor BINARY CURSOR FOR select * from pg_database")){// 1 means Ok
    int no_t=conn->Tuples();
    int no_f=conn->Fields();
    if (verbose) {
      cout << "The number of tuples in the query: " << conn->Tuples() << '\n';
      cout << "The number of fields in the query: " << conn->Fields() << '\n';
    }
    cout << "The query results: \n";
  
    for(int i=0;i < no_t; i++){
      for(int j=0;j < no_f; j++){
        cout << conn->GetValue(i,j) << '\t';
        //cout << conn->GetValue(i,j) << '\n';
      }
      cout << '\n';
    }
  } else{
    cout << "Execution of query failed\n";//conn
  }

  //conn->Exec("DECLARE mycursor BINARY CURSOR FOR select * from test");
  
  //return 0;
  
}



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* RE: [INTERFACES] Linking Errors
@ 2000-01-21 22:01 Ansley, Michael <Michael.Ansley@intec.co.za>
  0 siblings, 0 replies; 2+ messages in thread

From: Ansley, Michael @ 2000-01-21 22:01 UTC (permalink / raw)
  To: 'Mike ' <mfre@telusplanet.net>; pgsql-interfaces

>> 2. When I set the -lpq and -lpq++ I know it is suppose to be including
>> those libraries but do I need to tell the system where those libraries
>> are?  How does it know?
You add a -L switch to the command line to add library paths, and a -I
switch for include paths:

c++ -o test -L$PGHOME/lib -I$PGHOME/include -lpq -lpq++ test.c

or something...


MikeA



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2000-01-21 22:01 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-01-21 15:49 Linking Errors Mike <mfre@telusplanet.net>
2000-01-21 22:01 RE: [INTERFACES] Linking Errors Ansley, Michael <Michael.Ansley@intec.co.za>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox