PQsetdb

Started by Mohsen Pahlevanzadehabout 21 years ago9 messagesgeneral
Jump to latest
#1Mohsen Pahlevanzadeh
mohsen@pahlevanzadeh.org

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..................................

#2Richard Huxton
dev@archonet.com
In reply to: Mohsen Pahlevanzadeh (#1)
Re: PQsetdb

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

#3Mohsen Pahlevanzadeh
mohsen@pahlevanzadeh.org
In reply to: Richard Huxton (#2)
Re: PQsetdb

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

Show quoted text

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

#4Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Mohsen Pahlevanzadeh (#3)
Re: PQsetdb

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).

Show quoted text

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

#5Guy Rouillier
guyr@masergy.com
In reply to: Stephan Szabo (#4)
Re: PQsetdb

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

#6Mohsen Pahlevanzadeh
mohsen@pahlevanzadeh.org
In reply to: Stephan Szabo (#4)
Re: PQsetdb

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

Show quoted text

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

#7Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Mohsen Pahlevanzadeh (#6)
Re: PQsetdb

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?

#8Mohsen Pahlevanzadeh
mohsen@pahlevanzadeh.org
In reply to: Stephan Szabo (#7)
Re: PQsetdb

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
~

Show quoted text

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?

#9Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Mohsen Pahlevanzadeh (#8)
Re: PQsetdb

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.