Thread: Compiling Test Programs

Compiling Test Programs

From
Scott Holmes
Date:
I am by no means a C programmer and I don't know much about Makefiles so I 
need a little assistance here.  I have Postgresql7.1 compiled from the tar 
ball and it's working fine.  But now I need to write a program using libpg.  I 
have psql working fine as well as PHP4 so I've assumed libpg has been included 
in my installation.  But when I go to compile testlibpq.c  I get:

gcc -O2 -Wall -Wmissing-prototypes -Wmissing-declarations 
-I../../../src/interfaces/libpq -I../../../src/include   
-Wl,-rpath,/usr/local/pgsql/lib  testlibpq.c   -o testlibpq
/tmp/ccy2shMg.o: In function `exit_nicely':
/tmp/ccy2shMg.o(.text+0x7): undefined reference to `PQfinish'
/tmp/ccy2shMg.o: In function `main':
/tmp/ccy2shMg.o(.text+0x30): undefined reference to `PQsetdbLogin'
/tmp/ccy2shMg.o(.text+0x39): undefined reference to `PQstatus'
...
/tmp/ccy2shMg.o(.text+0x205): undefined reference to `PQfinish'
collect2: ld returned 1 exit status
make: *** [testlibpq] Error 1

I do have /usr/local/pgsql/lib/libpq.a

Perhaps someone can point me in the proper direction.





C++ interface on RH Linux 6.2

From
Carlos Moreno
Date:
Hi,

I'm compiling my applications on a RedHat 7.0 or 7.1 system, 
and had no trouble so far.  I include in my program the 
following:

#include <pgsql/libpq++.h>

And then, when compiling, I use the switches:

-I/usr/include/pgsql  and  -lpq++

Works fine.  But one of my students is trying to work on 
his machine at home (he has RH6.2), and is running into 
a couple of problems.  libpq++.h -- include file not found. 
I checked it, and the file was called libpq++.H 

When changing the include and compiling with the same 
switches, it did compile, but then when executing it, he 
got an error:  can not load runtime library *****.so*** 
(don't have the exact message here, but I remember it 
was about not being able to load the *.so* runtime lib)

I assume the default setup on RH6.2 is different than the 
new default setup on RH7+.  What should I (he) do?  Is 
there any documentation where I could find instructions 
for the various standard setups? 

Thanks!

Carlos
--


Re: C++ interface on RH Linux 6.2

From
Lamar Owen
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 14 May 2001 23:10, Carlos Moreno wrote:
> I'm compiling my applications on a RedHat 7.0 or 7.1 system,
> and had no trouble so far.  I include in my program the
> following:

> Works fine.  But one of my students is trying to work on
> his machine at home (he has RH6.2), and is running into
> a couple of problems.  libpq++.h -- include file not found.
> I checked it, and the file was called libpq++.H

First, upgrading the version of postgresql he has would be a good idea, as 
RedHat 6.2 shipped with PostgreSQL 6.5.3.  The upper-case .H is the giveaway 
there.

But, the C++ compiler isn't really great on RedHat6.2 --it works, but it 
isn't great.  The Red Hat 7.x compiler is, well, not very standard is some 
ways, but much more standard in others -- in particular, the C++ portion.

Upgrading to Red Hat 7.1 is a very good thing to do, IMHO.
- --
Lamar Owen
WGCR Internet Radio
1 Peter 4:11
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7AKwE5kGGI8vV9eERAqZ5AJoDw4oBbX9BFCI4OEsSMMnvQlElnACdH3pS
mzyImiy5zzjngUBqgwqOz3k=
=vwrI
-----END PGP SIGNATURE-----


Re: C++ interface on RH Linux 6.2

From
Carlos Moreno
Date:
Lamar Owen wrote:
> 
> First, upgrading the version of postgresql he has would be a good idea, as
> RedHat 6.2 shipped with PostgreSQL 6.5.3.

This would probably be the easiest thing for him.

> But, the C++ compiler isn't really great on RedHat6.2 --it works, but it
> isn't great.  The Red Hat 7.x compiler is, well, not very standard is some
> ways, but much more standard in others -- in particular, the C++ portion.
> 
> Upgrading to Red Hat 7.1 is a very good thing to do, IMHO.

He tried, since the setup that we have on the lab machines is RH7.1, 
so he would prefer to have the exact same setup (to avoid surprises 
and incompatibilities when he brings his homework/assignments from 
his machine to the College).  But for some reason that I find rather 
misterious, he tells me that he couldn't install RH7.1 ...  ???? 

(I'm having a hard time understanding how he could install RH6.2 
and it recognized the hardware, but he can't install RH7.1, which 
normally recognizes more easily any hardware configuration...) 

In any case, I think upgrading to the latest pgSQL would be the 
best option  (hmmm, I hope there are RPMs available  :-)) 

Thanks!!

Carlos
--


Re: Compiling Test Programs

From
Peter Eisentraut
Date:
Scott Holmes writes:

> gcc -O2 -Wall -Wmissing-prototypes -Wmissing-declarations
> -I../../../src/interfaces/libpq -I../../../src/include
> -Wl,-rpath,/usr/local/pgsql/lib  testlibpq.c   -o testlibpq
> /tmp/ccy2shMg.o: In function `exit_nicely':
> /tmp/ccy2shMg.o(.text+0x7): undefined reference to `PQfinish'
> /tmp/ccy2shMg.o: In function `main':
> /tmp/ccy2shMg.o(.text+0x30): undefined reference to `PQsetdbLogin'
> /tmp/ccy2shMg.o(.text+0x39): undefined reference to `PQstatus'
> ...
> /tmp/ccy2shMg.o(.text+0x205): undefined reference to `PQfinish'
> collect2: ld returned 1 exit status
> make: *** [testlibpq] Error 1

You need to link against libpq.  Add '-lpq' to the compilation line.

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter