c function - undefined symbols
c function - undefined symbols
От:
Steffn <steffn@gmx.at>
Дата:
I already asked this question on the psql-novice list, but didn't get
any reply. I am aware that this is probably a basic question and hope
someone here can point me in the right direction!
Hi!
I am currently trying my first steps in writing my own functions in C. I
read through the documentation and tried the most simple examples as
shown in . Sadly
this was already the point where I stumbled. I luckily compiled and
tested the add_one integer variant. But as soon as I added the
add_one_float8 I couldn't link no more. My linker dies with.
Undefined symbols:
"_Float8GetDatum", referenced from:
_add_one_float8 in foo.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Following the documentation I only added
"/Library/PostgreSQL/8.3/include/**" to my header search path. What else
do I need to configure?
Thanks for your help!
steffn
Environment used:
OS X 10.5.5
XCode 3.1
Postgres 8.3.4
Same behavior under WinXP and Ubuntu. So IMHO I am clearly missing a
point on configuring my build environment.
Re: c function - undefined symbols
От:
Richard Huxton <dev@archonet.com>
Дата:
Steffn wrote: > Undefined symbols: > "_Float8GetDatum", referenced from: > _add_one_float8 in foo.o > ld: symbol(s) not found > collect2: ld returned 1 exit status > > Following the documentation I only added > "/Library/PostgreSQL/8.3/include/**" to my header search path. What else > do I need to configure? I'm not a "C" hacker, but that's failing at the linking stage, not the compiling stage. Are you missing the right lib to go with your headers? -- Richard Huxton Archonet Ltd
Re: c function - undefined symbols
От:
Steffn <steffn@gmx.at>
Дата:
Hi! Thanks for your reply. Yes, thats also my suspicion. But what library to include? I added /Library/PostgreSQL/8.3/lib/** to my library search path, but it won't help. If I knew which library I have to add, I think I can figure out how to properly configure my build settings. Couldn't find any hints in the docu nor in the mailing list. Thanks, steffn Richard Huxton wrote, On 12/10/08 11:21 AM: > Steffn wrote: > >> Undefined symbols: >> "_Float8GetDatum", referenced from: >> _add_one_float8 in foo.o >> ld: symbol(s) not found >> collect2: ld returned 1 exit status >> >> Following the documentation I only added >> "/Library/PostgreSQL/8.3/include/**" to my header search path. What else >> do I need to configure? >> > > I'm not a "C" hacker, but that's failing at the linking stage, not the > compiling stage. Are you missing the right lib to go with your headers? > > >
Re: c function - undefined symbols
От:
Quan Zongliang <quanzongliang@gmail.com>
Дата:
> I added /Library/PostgreSQL/8.3/lib/** to my library search path, Try to add "-L/PostgreSQL/8.3/lib -lpg" options to linker's command line. You can get details with "ld --help". Good luck. ----------------------------------------------- Quan Zongliang quanzongliang@gmail.com CIT Japan: http://www.cit.co.jp CIT China: http://www.citbj.com.cn
Re: c function - undefined symbols
От:
"Albe Laurenz" <laurenz.albe@wien.gv.at>
Дата:
Steffn wrote: > I am currently trying my first steps in writing my own functions in C. I > read through the documentation and tried the most simple examples as shown in > . Sadly > this was already the point where I stumbled. I luckily compiled and > tested the add_one integer variant. But as soon as I added the > add_one_float8 I couldn't link no more. My linker dies with. > > Undefined symbols: > "_Float8GetDatum", referenced from: > _add_one_float8 in foo.o > ld: symbol(s) not found > collect2: ld returned 1 exit status > > Following the documentation I only added > "/Library/PostgreSQL/8.3/include/**" to my header search path. What else > do I need to configure? I guess that the include path you need is /Library/PostgreSQL/8.3/include/server. Where in the documentation did you find the path? I read the following in http://www.postgresql.org/docs/8.3/static/xfunc-c.html#AEN40954 "Use pg_config --includedir-server to find out where the PostgreSQL server header files are installed on your system" What is the result of "pg_config --includedir-server" for you? Yours, Laurenz Albe
Re: c function - undefined symbols
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Steffn writes: > Thanks for your reply. Yes, thats also my suspicion. But what library to > include? There is no library to include --- you need to be building *your* code as a library that can be loaded into the Postgres backend, which will supply the missing function. This is somewhat platform-specific and frankly I'd suggest using pgxs rather than puzzling it out for yourself. See http://www.postgresql.org/docs/8.3/static/xfunc-c.html#XFUNC-C-PGXS regards, tom lane