Обсуждение: libpq++ compiling errors...

Поиск
Список
Период
Сортировка

libpq++ compiling errors...

От
"isaac flemmin"
Дата:
<div class="Section1"><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Hello again,</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Okay, now that I have some time to concentrate on getting programs using the libpq and/or libpq++ to
compileI will try this message again. I am using PostgreSQL 7.1.3, glibc-2.2.4-19.3 and gcc-2.96-85. Any time I try to
compilea program that uses the libpq or the libpq++ headers or libraries i get errors. When I installed PostgreSQL i
usedboth make install, and make install-all-headers to ensure that all the header files were copied to the system and I
didboth the commands as root. I have included some of the output I get when I try compiling different
ways.</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">The first example is when I try to run make in the libpq++/examples directory.</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">PWD = /home/tech/isaac/postgres/postgresql-7.1.3/src/interfaces/libpq++/examples</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">g++  -I/usr/local/pgsql/include -o testlibpq0 testlibpq0.cc -L/usr/local/pgsql/lib
-lpq++</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">In file included from testlibpq0.cc:18:</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial">../libpq++.h:27:34: libpq++/pgconnection.h: No such file or directory</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">../libpq++.h:28:32: libpq++/pgdatabase.h: No such file or directory</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">../libpq++.h:29:31: libpq++/pglobject.h: No such file or directory</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">../libpq++.h:30:31: libpq++/pgtransdb.h: No such file or directory</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">../libpq++.h:31:32: libpq++/pgcursordb.h: No such file or directory</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">make: *** [testlibpq0] Error 1</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">The second set of errors is after I manually copy the libpq++ header file dir to
/usr/local/pgsql/include/and try to run make again. I am not sure why but the command “make install-all-headers” did
notput the libpq++ headers into the pgsql/include. If anyone has any reasons why this might be I would be more than
happyto learn.</span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">g++  -I/usr/local/pgsql/include -o testlibpq0 testlibpq0.cc -L/usr/local/pgsql/lib
-lpq++</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">In file included from ../libpq++.h:27,</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial">                 from testlibpq0.cc:18:</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial">/usr/local/pgsql/include/libpq++/pgconnection.h:85: syntax error before `('</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">In file included from ../libpq++.h:29,</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial">                 from testlibpq0.cc:18:</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial">/usr/local/pgsql/include/libpq++/pglobject.h:36: syntax error before `;'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">/usr/local/pgsql/include/libpq++/pglobject.h:55: syntax error before `('</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">In file included from ../libpq++.h:31,</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial">                 from testlibpq0.cc:18:</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial">/usr/local/pgsql/include/libpq++/pgcursordb.h:47: parse error before `&'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">/usr/local/pgsql/include/libpq++/pgcursordb.h:54: parse error before `&'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">/usr/local/pgsql/include/libpq++/pgcursordb.h:57: parse error before `&'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">/usr/local/pgsql/include/libpq++/pgcursordb.h:60: syntax error before `;'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">/usr/local/pgsql/include/libpq++/pgcursordb.h: In method `const char *PgCursor::Cursor ()
const':</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">/usr/local/pgsql/include/libpq++/pgcursordb.h:53: `pgCursor' undeclared (first use this
function)</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">/usr/local/pgsql/include/libpq++/pgcursordb.h:53: (Each undeclared identifier is reported only once
for</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">each function it appears in.)</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial">/usr/local/pgsql/include/libpq++/pgcursordb.h: In method `void PgCursor::Cursor
(...)':</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">/usr/local/pgsql/include/libpq++/pgcursordb.h:54: `cursor' undeclared (first use this
function)</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq0.cc: In function `int main ()':</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial">testlibpq0.cc:34: `string' undeclared (first use this function)</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq0.cc:34: parse error before `;'</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial">testlibpq0.cc:40: `buf' undeclared (first use this function)</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq0.cc:40: `getline' undeclared (first use this function)</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">I could give many more examples where I try linking in or including the libraries by hand, etc...but
itall comes out basically the same way. I get one of two types of errors, either it cannot fine the included header
files,or it lists errors from them. That is just the libpq++. I will now move on to my dealings with libpq, which are
muchthe same.</span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">This is an example when i try to make in the src/test/examples directory.</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">gcc  -Wl,-rpath,/usr/local/pgsql/lib  testlibpq.o   -o testlibpq</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o: In function `main':</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial">testlibpq.o(.text+0x1c): undefined reference to `PQsetdbLogin'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x28): undefined reference to `PQstatus'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x4c): undefined reference to `PQerrorMessage'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x6b): undefined reference to `PQfinish'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x8d): undefined reference to `PQexec'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x97): undefined reference to `PQresultStatus'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0xb9): undefined reference to `PQclear'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0xc3): undefined reference to `PQfinish'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0xd8): undefined reference to `PQclear'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0xe8): undefined reference to `PQexec'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0xf2): undefined reference to `PQresultStatus'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x114): undefined reference to `PQclear'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x11e): undefined reference to `PQfinish'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x135): undefined reference to `PQclear'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x145): undefined reference to `PQexec'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x14f): undefined reference to `PQresultStatus'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x173): undefined reference to `PQclear'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x17d): undefined reference to `PQfinish'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x197): undefined reference to `PQnfields'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x1c8): undefined reference to `PQfname'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x1e8): undefined reference to `PQfname'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x209): undefined reference to `PQfname'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x222): undefined reference to `PQfname'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x23b): undefined reference to `PQfname'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x257): more undefined references to `PQfname' follow</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o: In function `main':</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial">testlibpq.o(.text+0x2b3): undefined reference to `PQgetvalue'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x2d0): undefined reference to `PQgetvalue'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x2f7): undefined reference to `PQgetvalue'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x313): undefined reference to `PQgetvalue'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x32f): undefined reference to `PQgetvalue'</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x34e): more undefined references to `PQgetvalue' follow</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o: In function `main':</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial">testlibpq.o(.text+0x37e): undefined reference to `PQntuples'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x392): undefined reference to `PQclear'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x3a2): undefined reference to `PQexec'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x3ac): undefined reference to `PQclear'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x3bc): undefined reference to `PQexec'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x3c6): undefined reference to `PQclear'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">testlibpq.o(.text+0x3d0): undefined reference to `PQfinish'</span></font><p class="MsoNormal"><font
face="Arial"size="2"><span style="font-size:10.0pt; 
font-family:Arial">collect2: ld returned 1 exit status</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial">make: *** [testlibpq] Error 1</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">I have not actually tried to write any programs myself because I cannot even get the example
programsto compile so I do not see the point. If anyone has any idea what might be going wrong, or what I may not be
understandingcorrectly I would be very grateful for your help. Even if it turns out I’m just being stupid and missing
something,I don’t mind finding that out. I just want to be able to compile programs that use either the libpq or the
libpq++.</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Thanks</span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Isaac</span></font></div>

Re: libpq++ compiling errors...

От
Oliver Elphick
Дата:
On Wed, 2002-01-30 at 00:53, isaac flemmin wrote:

> g++  -I/usr/local/pgsql/include -o testlibpq0 testlibpq0.cc
> -L/usr/local/pgsql/lib -lpq++
>
> In file included from ../libpq++.h:27,
>
>                  from testlibpq0.cc:18:
>
> /usr/local/pgsql/include/libpq++/pgconnection.h:85: syntax error before
> `('
>
> In file included from ../libpq++.h:29,
>
>                  from testlibpq0.cc:18:
>
> /usr/local/pgsql/include/libpq++/pglobject.h:36: syntax error before `;'

I have very little experience of C++, but all these errors relate to the
string class; it appears not to be provided by your class library.
pgconnection.h appears to contemplate the possibility, since the
inclusion of string.h is enclosed in an #ifdef, but there is no
alternative provided.

I think that libpq++ is very poorly tested.  If you look back in the
archives a week or two, you will find mention of a new C++ interface
that would replace libpq++.



> gcc  -Wl,-rpath,/usr/local/pgsql/lib  testlibpq.o   -o testlibpq
>
> testlibpq.o: In function `main':
>
> testlibpq.o(.text+0x1c): undefined reference to `PQsetdbLogin'


This is a link error; the command does not link the libpq library into
the executable.  You need to add "-lpq" to the link options.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
    "The Lord knoweth how to deliver the godly out of      temptations, and to reserve the unjust unto the day of
judgmentto be punished;"            II Peter 2:9  

Re: libpq++ compiling errors...

От
"isaac flemmin"
Дата:
Thanks for the reply,

I do know that I have included <string.h> for other programs, and that
it does not have anything to do with C++ Strings. I will just not use
libpq++ if is not tested or of poor quality. I am fine using libpq, it
really does not matter to me. I was just hoping one or the other would
work for me. So with that said, is there anything else that might be
causing these errors other than string.h, and if not how do I get the
libpq libraries to work with string.h?

When I try to add -lpq to the link options I get libpq.so.2 not found.
Is there a something special I need to do to add that? Here is the
command's I have tried.

First I compile without linking.
gcc -c testlibpq.c -I/usr/local/pgsql/include/

Then I link using the -lpq and the directory is is in
gcc -o testlibpq testlibpq.o -L/usr/local/pgsql/lib/ -lpq

Then I try to run the program.
./testlibpq
./testlibpq: error while loading shared libraries: libpq.so.2: cannot
open shared object file: No such file or directory

Since it does not seem to be able to find it I try looking at what all
it needs using the ldd command. Once again it says not found.
ldd testlibpq       libpq.so.2 => not found       libc.so.6 => /lib/i686/libc.so.6 (0x4001b000)
/lib/ld-linux.so.2=> /lib/ld-linux.so.2 (0x40000000)
 

So now I actually look for the library myself, and it is obviously on
the computer in several place.
locate libpq.so.2
/home/tech/isaac/postgres/postgresql-7.1.3/src/interfaces/libpq/libpq.so
.2.1
/home/tech/isaac/postgres/postgresql-7.1.3/src/interfaces/libpq/libpq.so
.2
/home/tech/isaac/postgres/postgresql-7.1.3/src/test/regress/tmp_check/in
stall/usr/local/pgsql/lib/libpq.so.2
/home/tech/isaac/postgres/postgresql-7.1.3/src/test/regress/tmp_check/in
stall/usr/local/pgsql/lib/libpq.so.2.1
/usr/local/pgsql/lib/libpq.so.2
/usr/local/pgsql/lib/libpq.so.2.1

I have never installed any libraries on a Linux system before. Are there
any tutorials out there that can teach me how to do this, or does anyone
know how to do it that would not mind telling me. I am currently looking
for anything I can find but am not having much luck. I will continue
looking but if anyone can help push me in the right direction I would be
very grateful. 

Thanks for all the help so far.
Isaac

-----Original Message-----
From: pgsql-interfaces-owner@postgresql.org
[mailto:pgsql-interfaces-owner@postgresql.org] On Behalf Of Oliver
Elphick
Sent: Tuesday, January 29, 2002 10:53 PM
To: isaac flemmin
Cc: pgsql-interfaces@postgresql.org
Subject: Re: [INTERFACES] libpq++ compiling errors...

On Wed, 2002-01-30 at 00:53, isaac flemmin wrote:

> g++  -I/usr/local/pgsql/include -o testlibpq0 testlibpq0.cc
> -L/usr/local/pgsql/lib -lpq++
> 
> In file included from ../libpq++.h:27,
> 
>                  from testlibpq0.cc:18:
> 
> /usr/local/pgsql/include/libpq++/pgconnection.h:85: syntax error
before
> `('
> 
> In file included from ../libpq++.h:29,
> 
>                  from testlibpq0.cc:18:
> 
> /usr/local/pgsql/include/libpq++/pglobject.h:36: syntax error before
`;'

I have very little experience of C++, but all these errors relate to the
string class; it appears not to be provided by your class library. 
pgconnection.h appears to contemplate the possibility, since the
inclusion of string.h is enclosed in an #ifdef, but there is no
alternative provided.

I think that libpq++ is very poorly tested.  If you look back in the
archives a week or two, you will find mention of a new C++ interface
that would replace libpq++.



> gcc  -Wl,-rpath,/usr/local/pgsql/lib  testlibpq.o   -o testlibpq
> 
> testlibpq.o: In function `main':
> 
> testlibpq.o(.text+0x1c): undefined reference to `PQsetdbLogin'


This is a link error; the command does not link the libpq library into
the executable.  You need to add "-lpq" to the link options.

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
    "The Lord knoweth how to deliver the godly out of      temptations, and to reserve the unjust unto the day of
judgmentto be punished;"            II Peter 2:9 
 



Re: libpq++ compiling errors...

От
Andreas Kretzer
Дата:
isaac flemmin wrote:

> ...
> When I try to add -lpq to the link options I get libpq.so.2 not found.
> Is there a something special I need to do to add that? Here is the
> command's I have tried.

So have a look at where the libpq is installed and add that path to your
/etc/ld.so.conf and call 'ldconfig'. You should also check that you have
the libpq.so.2 beeing a symbolic link to the real library called 'libpq.so.2.xx'
where 'xx' is the real minor version number. There should also be symbolic
link called libpq.so pointing to your libpq.so.2!

Maybe you forgot to 'make install' all that stuff and have therefor all these
problems ???? Remember: There are some include files installed too.
Usually all this stuff goes to /usr/local/pgsql/lib and /usr/local/pgsql/include
respectively. So you should have an include-path for compilation pointing
to the mentioned include directory and the libpath added to /etc/ld.so.conf.

Hope this helps

Andreas



Re: libpq++ compiling errors...

От
jtv
Дата:
On Wed, Jan 30, 2002 at 12:52:48AM -0800, isaac flemmin wrote:
> 
> I do know that I have included <string.h> for other programs, and that
> it does not have anything to do with C++ Strings. 

Right.  <string.h> is for the C string manipulation functions.  The
C++ string type is defined in <string>.

Also note that depending on your compiler (and compiler version), the
standard string type may be known as just "string", or as the more
modern "std::string". 


Jeroen



Re: libpq++ compiling errors...

От
Patrick Welche
Дата:
While we're on the subject, I find it strange that I need to add

CPPFLAGS+=-I${PGSQL}/include/internal

as libpq++.h -> libpq++/pgconnection.h -> postgres_fe.h which is in fact
internal/postgres_fe.h

Header file spaghetti?

Patrick


Re: libpq++ compiling errors...

От
Peter Eisentraut
Дата:
Patrick Welche writes:

> While we're on the subject, I find it strange that I need to add
>
> CPPFLAGS+=-I${PGSQL}/include/internal
>
> as libpq++.h -> libpq++/pgconnection.h -> postgres_fe.h which is in fact
> internal/postgres_fe.h
>
> Header file spaghetti?

Yes, but it's fixed in whatever the latest beta is right now.

-- 
Peter Eisentraut   peter_e@gmx.net



Re: libpq++ compiling errors...

От
Tom Lane
Дата:
Patrick Welche <prlw1@newn.cam.ac.uk> writes:
> While we're on the subject, I find it strange that I need to add
> CPPFLAGS+=-I${PGSQL}/include/internal
> as libpq++.h -> libpq++/pgconnection.h -> postgres_fe.h which is in fact
> internal/postgres_fe.h

This is fixed as of RC2, I believe.
        regards, tom lane


Re: libpq++ compiling errors...

От
Patrick Welche
Дата:
On Thu, Jan 31, 2002 at 08:51:35PM -0500, Peter Eisentraut wrote:
> Patrick Welche writes:
> 
> > While we're on the subject, I find it strange that I need to add
> >
> > CPPFLAGS+=-I${PGSQL}/include/internal
> >
> > as libpq++.h -> libpq++/pgconnection.h -> postgres_fe.h which is in fact
> > internal/postgres_fe.h
> >
> > Header file spaghetti?
> 
> Yes, but it's fixed in whatever the latest beta is right now.

Great - already downloaded source (I was still on beta4)

Cheers,

Patrick