Thread: PQsetdb

PQsetdb

From
"Mohsen Pahlevanzadeh"
Date:
Dears,I have added following constructor to my class:
class CPgsql : public CCore
{
 public:
       char       *pghost,
                  *pgport,
                  *pgoptions,
                  *pgtty;
        char       *dbName;
        PGconn *connection2db;
        const char * conninfo;
        CPgsql(const char *dbname);
};
CPgsql::CPgsql(const char *dbname)
{
 pghost=NULL;
 pgport=NULL;
 pgoptions=NULL;
 pgtty=NULL;
 dbName=(char*)dbname;
 connection2db=PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);
}//end of constructor
But when i call it ,for example :
CPgsql p("x");
I recieve following error:
[root@localhost sql2sql]# make
g++ -c -I/usr/include/mysql  -I/usr/include sql2sql.cpp;
g++ -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib -o
sql2sql sql2sql.o ;
sql2sql.o(.text+0x6c): In function `CPgsql::CPgsql[not-in-charge](char
const*)':
: undefined reference to `PQsetdbLogin'
sql2sql.o(.text+0x10e): In function `CPgsql::CPgsql[in-charge](char const*)':
: undefined reference to `PQsetdbLogin'
collect2: ld returned 1 exit status
make: *** [sql2sql] Error 1

Please help me..................................



Re: PQsetdb

From
Richard Huxton
Date:
Mohsen Pahlevanzadeh wrote:
> I recieve following error:
> [root@localhost sql2sql]# make
> g++ -c -I/usr/include/mysql  -I/usr/include sql2sql.cpp;
                        ^^^^^^
> g++ -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib -o
                  ^^^^^   ^^^^^^^^^^^
Those aren't going to help, are they?

--
   Richard Huxton
   Archonet Ltd

Re: PQsetdb

From
"Mohsen Pahlevanzadeh"
Date:
My program is using both MySQL & PostgreSQL.I don't have problem with
Mysql.But i have problem with pgsql.
> Mohsen Pahlevanzadeh wrote:
>> I recieve following error:
>> [root@localhost sql2sql]# make
>> g++ -c -I/usr/include/mysql  -I/usr/include sql2sql.cpp;
>                         ^^^^^^
>> g++ -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib -o
>                   ^^^^^   ^^^^^^^^^^^
> Those aren't going to help, are they?
>
> --
>    Richard Huxton
>    Archonet Ltd
>


Re: PQsetdb

From
Stephan Szabo
Date:
On Wed, 23 Feb 2005, Mohsen Pahlevanzadeh wrote:

> My program is using both MySQL & PostgreSQL.I don't have problem with
> Mysql.But i have problem with pgsql.

That could be because you don't appear to be linking to the PostgreSQL
libraries (as Richard was hinting at).

> > Mohsen Pahlevanzadeh wrote:
> >> I recieve following error:
> >> [root@localhost sql2sql]# make
> >> g++ -c -I/usr/include/mysql  -I/usr/include sql2sql.cpp;
> >                         ^^^^^^
> >> g++ -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib -o
> >                   ^^^^^   ^^^^^^^^^^^
> > Those aren't going to help, are they?
> >
> > --
> >    Richard Huxton
> >    Archonet Ltd
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>                http://archives.postgresql.org
>

Re: PQsetdb

From
"Guy Rouillier"
Date:
Mohsen Pahlevanzadeh wrote:
> My program is using both MySQL & PostgreSQL.I don't have problem with
> Mysql.  But i have problem with pgsql.

I think Richard's point is that you are not linking in any PostgreSQL
libs.


>> Mohsen Pahlevanzadeh wrote:
>>> I recieve following error:
>>> [root@localhost sql2sql]# make
>>> g++ -c -I/usr/include/mysql  -I/usr/include sql2sql.cpp;
>>                         ^^^^^^
>>> g++ -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib
>>> g++ -o
>>                   ^^^^^   ^^^^^^^^^^^
>> Those aren't going to help, are they?
>>
>> --
>>    Richard Huxton
>>    Archonet Ltd
>>

--
Guy Rouillier


Re: PQsetdb

From
"Mohsen Pahlevanzadeh"
Date:
If you see my orginal email,I mentioned to link to inc & lib for
pgsql.Even when i use PQsetdb,I didn't recieve error message for using
PQsetdb.
Yours,Mohsen
>
> On Wed, 23 Feb 2005, Mohsen Pahlevanzadeh wrote:
>
>> My program is using both MySQL & PostgreSQL.I don't have problem with
>> Mysql.But i have problem with pgsql.
>
> That could be because you don't appear to be linking to the PostgreSQL
> libraries (as Richard was hinting at).
>
>> > Mohsen Pahlevanzadeh wrote:
>> >> I recieve following error:
>> >> [root@localhost sql2sql]# make
>> >> g++ -c -I/usr/include/mysql  -I/usr/include sql2sql.cpp;
>> >                         ^^^^^^
>> >> g++ -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib
>> -o
>> >                   ^^^^^   ^^^^^^^^^^^
>> > Those aren't going to help, are they?
>> >
>> > --
>> >    Richard Huxton
>> >    Archonet Ltd
>> >
>>
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 6: Have you searched our list archives?
>>
>>                http://archives.postgresql.org
>>
>


Re: PQsetdb

From
Stephan Szabo
Date:
sszabo@bigpanda.com

On Wed, 23 Feb 2005, Mohsen Pahlevanzadeh wrote:

> If you see my orginal email,I mentioned to link to inc & lib for
> pgsql.Even when i use PQsetdb,I didn't recieve error message for using
> PQsetdb.


The fragment of execution of make you gave had no mention of them in the
commandlines shown.  What does your Makefile look like?



Re: PQsetdb

From
"Mohsen Pahlevanzadeh"
Date:
My Makefile is :
mysql_INCS=-I/usr/include/mysql
pgsql_INCS=-I/usr/include
pgsql_LIBS=-L/usr/lib
mysql_LIBS=-L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm
CXX=g++
sql2sql : sql2sql.o
        $(CXX) $(mysql_LIBS) $(pgsql_LIBS) -o sql2sql sql2sql.o ;
        rm -rf sql2sql.o ;
sql2sql.o : sql2sql.cpp
        $(CXX) -c $(mysql_INCS) $(pgsql_INCS) sql2sql.cpp;
clean :
        rm -rf sql2sql.o
        rm -rf sql2sql
~

> sszabo@bigpanda.com
>
> On Wed, 23 Feb 2005, Mohsen Pahlevanzadeh wrote:
>
>> If you see my orginal email,I mentioned to link to inc & lib for
>> pgsql.Even when i use PQsetdb,I didn't recieve error message for using
>> PQsetdb.
>
>
> The fragment of execution of make you gave had no mention of them in the
> commandlines shown.  What does your Makefile look like?
>
>
>


Re: PQsetdb

From
Stephan Szabo
Date:
On Wed, 23 Feb 2005, Mohsen Pahlevanzadeh wrote:

> pgsql_LIBS=-L/usr/lib

You need to specify to link to an actual library here (probably -lpq at
least).  Just giving a library directory isn't going to be good enough.