By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,264 Members | 1,774 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,264 IT Pros & Developers. It's quick & easy.

A "linking" Question

P: n/a
Let me explain:

I have written a "C" function which contains calls to other functions, all of
which work with an API to a mileage database product called PCMiler. These
functions make connections to the PCMiler databae, do error checking on the
origin and destination, get directions, etc. There is only one function
loaded into postgres and it makes calls to everything else. I create a shared
object library containing one object file: pcmiler.o and also containing a
link to the PCMiler SO, libpcmsrv.so. Here is the make file code:

libpcmiler.so: utility/pcmiler.h logpro.h utility/pcmiler.c
rm libpcmiler* -f
gcc -Wall -fPIC $(APPINC) -DUNIX -c utility/pcmiler.c
gcc -shared -W1,-soname,libpcmiler.so.1 $(PCMSRVLIB) -o libpcmiler.so.1.0
pcmiler.o
ln -s libpcmiler.so.1.0 libpcmiler.so.1
ln -s libpcmiler.so.1 libpcmiler.so
psql rnd < sqlfunc/loadCfuncs.sql

The function loads into postgres and everything works flawlessly. Now, we have
an X-Windows front end to this application which is a transportation app.
Obviously, we need to do lots of mileage lookups. There are times when I need
to make call to some of the functions residing in pcmiler.c bypassing the
call to the postgres function. I thought I could simply link my pcmiler
shared library with my app binary, but I get errors when I do that. Here they
are:
pcmiler.o(.text+0x8d): In function `PCMilerConnect':
: undefined reference to `elog'
pcmiler.o(.text+0x12a): In function `PCMGetMiles':
: undefined reference to `elog'
pcmiler.o(.text+0x166): In function `PCMGetMiles':
: undefined reference to `elog'
pcmiler.o(.text+0x3c3): In function `psql_pcmgetmiles':
: undefined reference to `pg_detoast_datum'
pcmiler.o(.text+0x3d7): In function `psql_pcmgetmiles':
: undefined reference to `pg_detoast_datum'
pcmiler.o(.text+0x3ff): In function `psql_pcmgetmiles':
: undefined reference to `CurrentMemoryContext'
pcmiler.o(.text+0x406): In function `psql_pcmgetmiles':
: undefined reference to `MemoryContextAlloc'
pcmiler.o(.text+0x423): In function `psql_pcmgetmiles':
: undefined reference to `CurrentMemoryContext'
pcmiler.o(.text+0x42a): In function `psql_pcmgetmiles':
: undefined reference to `MemoryContextAlloc'
pcmiler.o(.text+0x48a): In function `psql_pcmgetmiles':
: undefined reference to `elog'
pcmiler.o(.text+0x4dc): In function `psql_pcmgetmiles':
: undefined reference to `pfree'
pcmiler.o(.text+0x4ea): In function `psql_pcmgetmiles':
: undefined reference to `pfree'
pcmiler.o(.text+0x51f): In function `psql_pcmgetmiles':
: undefined reference to `Float8GetDatum'
collect2: ld returned 1 exit status
make: *** [logpro] Error 1

All the complaints are regarding pgsql server functions. Obviously, I need to
link with some sort of library, but I don't know which one. I'm already
linking with libpq and I tried libepcg but that didn't work. I'm not very
knowledgeable regarding some of these things so please excuse my ingorance.
Can somebody give me a clue as to the error of my ways?

Thanks...

--
Quote: 6
"[G]un control often serves as a gateway to tyranny. Tyrants from Hitler
to Mao to Stalin have sought to disarm their own citizens, for the simple
reason that unarmed people are easier to control. Our Founders, having
just expelled the British army, knew that the right to bear arms serves
as the guardian of every other right. This is the principle so often
ignored by both sides in the gun control debate. Only armed citizens can
resist tyrannical government."

--Ron Paul

Work: 1-336-372-6812
Cell: 1-336-363-4719
email: te***@esc1.com

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Thu, Jun 03, 2004 at 09:08:40AM -0400, Terry Lee Tucker wrote:
Let me explain:

I have written a "C" function which contains calls to other functions, all of
which work with an API to a mileage database product called PCMiler. These
functions make connections to the PCMiler databae, do error checking on the
origin and destination, get directions, etc. There is only one function
loaded into postgres and it makes calls to everything else. I create a shared
object library containing one object file: pcmiler.o and also containing a
link to the PCMiler SO, libpcmsrv.so. Here is the make file code:
<snip>
All the complaints are regarding pgsql server functions. Obviously, I need to
link with some sort of library, but I don't know which one. I'm already
linking with libpq and I tried libepcg but that didn't work. I'm not very
knowledgeable regarding some of these things so please excuse my ingorance.
Can somebody give me a clue as to the error of my ways?
There is no library with those functions. They exist within the server
binary itself and are exported to dynamically linked modules that are
loaded in.

I think you need to split your library in two, one part which depends
on being loaded into postgresql and the part that can be used standalone.

--
Martijn van Oosterhout <kl*****@svana.org> http://svana.org/kleptog/ Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
tool for doing 5% of the work and then sitting around waiting for someone
else to do the other 95% so you can sue them.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFAvyyeY5Twig3Ge+YRAoJmAKDGSV58U6iJOw9VFbb/2LUAm8E4dACgj0Fk
hibPvJCWJPRJM04quNCyzsc=
=wIb/
-----END PGP SIGNATURE-----

Nov 23 '05 #2

P: n/a
Ah, that's the information I needed. I already have a "split" version, I just
wanted to know if it was possible to it the other way. You've been very
helpful.

Thanks...

On Thursday 03 June 2004 09:50 am, Martijn van Oosterhout saith:
On Thu, Jun 03, 2004 at 09:08:40AM -0400, Terry Lee Tucker wrote:
Let me explain:

I have written a "C" function which contains calls to other functions,
all of which work with an API to a mileage database product called
PCMiler. These functions make connections to the PCMiler databae, do
error checking on the origin and destination, get directions, etc. There
is only one function loaded into postgres and it makes calls to
everything else. I create a shared object library containing one object
file: pcmiler.o and also containing a link to the PCMiler SO,
libpcmsrv.so. Here is the make file code:


<snip>
All the complaints are regarding pgsql server functions. Obviously, I
need to link with some sort of library, but I don't know which one. I'm
already linking with libpq and I tried libepcg but that didn't work. I'm
not very knowledgeable regarding some of these things so please excuse my
ingorance. Can somebody give me a clue as to the error of my ways?


There is no library with those functions. They exist within the server
binary itself and are exported to dynamically linked modules that are
loaded in.

I think you need to split your library in two, one part which depends
on being loaded into postgresql and the part that can be used standalone.


--

Work: 1-336-372-6812
Cell: 1-336-363-4719
email: te***@esc1.com

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.