External C functions
Posted in 2013
A user asked where to find documentation and examples for writing C user-defined functions for Informix. Answers pointed to the "User-Defined Routines and Data Types Developer's Guide" and DataBlade API reference, John Miller's IIUG conference session "Writing C-UDR (User Defined Routines) the basics", and Fernando Nunes' blog examples. He then hit AIX 6.1 link errors (undefined mi_* and rupshift symbols), as those symbols live in oninit and are resolved when the shared object is loaded. Resolution: build a proper shared library, adding "-G -bexpall -bnoentry" to the link line, which worked.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: General Discussion
I would like to add a function to my Informix database, and would like to use C for the external tool. Can someone point me to some good documentation with examples? Thanks.
Check out the "User-Defined Routines and Data Types Developer's Guide" manual included in the PDF documentation set. Art Art S. Kagel Advanced DataTools (www.advancedatatools.com) Blog: http://informix-myview.blogspot.com/ Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Advanced DataTools, the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves. On Tue, Apr 16, 2013 at 3:26 PM, JOHN CALLICOTTE <john.callicotte@ottawa.edu > wrote: > I would like to add a function to my Informix database, and would like to > use > C for the external tool. Can someone point me to some good documentation > with > examples? Thanks. > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --089e013d1010722b3604da7f8932
If you goto the iiug.org website and look at last years conference presentation I did a presentation that takes you step by step in adding C-Function into the database server. The title is "Writing C-UDR (User Defined Routines) the basics" Session C02 John F. Miller III STSM, Lead Architect miller3@us.ibm.com 503-747-1366 IBM Informix Dynamic Server (IDS) ids-bounces@iiug.org wrote on 04/16/2013 12:26:46 PM: > From: "JOHN CALLICOTTE" <john.callicotte@ottawa.edu> > To: ids@iiug.org, > Date: 04/16/2013 12:27 PM > Subject: External C functions [30071] > Sent by: ids-bounces@iiug.org > > I would like to add a function to my Informix database, and would like to use > C for the external tool. Can someone point me to some good documentation with > examples? Thanks. > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. >
Thanks! This is perfect.
Good documentation equals the UDR Developer's guide. Also check the Datablade API function reference. For a few examples (very simple use cases) I suggest this: http://informix-technology.blogspot.pt/search?q=%22C+UDR%22 You should also be able to find previous IIUG conference presentations in the IIUG web site. Regards On Tue, Apr 16, 2013 at 8:26 PM, JOHN CALLICOTTE <john.callicotte@ottawa.edu > wrote: > I would like to add a function to my Informix database, and would like to > use > C for the external tool. Can someone point me to some good documentation > with > examples? Thanks. > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > -- Fernando Nunes Portugal http://informix-technology.blogspot.com My email works... but I don't check it frequently... --f46d043d64af5d490404da808308
The jfm_return example worked great, but I can't get the jfm_upshift to link. I get: xlc -q64 -qmkshrobj -o jfm_upshift.so jfm_upshift.o -L/home/carsids/callj/lib/common -lcommon -lc -L/opt/informix/lib/dmi -lthdmi ld: 0711-317 ERROR: Undefined symbol: .mi_switch_mem_duration ld: 0711-317 ERROR: Undefined symbol: .mi_lvarchar_to_string ld: 0711-317 ERROR: Undefined symbol: .rupshift ld: 0711-317 ERROR: Undefined symbol: .mi_string_to_lvarchar ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. make: *** [jfm_upshift.so] Error 8 This is on AIX 6.1. I tried the libdmi.a, libifdmi.a, and finally libthdmi.a. Which library should I be linking in? Thanks.
I believe the problem is with the linking.
These functions are defined in "oninit" and will be resolved once the
shared library is loaded. You just need to tell the linker to look for
them later.
John F. Miller III
STSM, Lead Architect
miller3@us.ibm.com
503-747-1366
IBM Informix Dynamic Server (IDS)
ids-bounces@iiug.org wrote on 04/18/2013 07:34:54 AM:
> From: "JOHN CALLICOTTE" <john.callicotte@ottawa.edu>
> To: ids@iiug.org,
> Date: 04/18/2013 07:41 AM
> Subject: Re: External C functions [30108]
> Sent by: ids-bounces@iiug.org
>
> The jfm_return example worked great, but I can't get the jfm_upshiftto
link.
> I get:
>
> xlc -q64 -qmkshrobj -o jfm_upshift.so jfm_upshift.o
> -L/home/carsids/callj/lib/common -lcommon -lc -L/opt/informix/lib/dmi
-lthdmi
> ld: 0711-317 ERROR: Undefined symbol: .mi_switch_mem_duration
> ld: 0711-317 ERROR: Undefined symbol: .mi_lvarchar_to_string
> ld: 0711-317 ERROR: Undefined symbol: .rupshift
> ld: 0711-317 ERROR: Undefined symbol: .mi_string_to_lvarchar
> ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
> information.
> make: *** [jfm_upshift.so] Error 8
>
> This is on AIX 6.1. I tried the libdmi.a, libifdmi.a, and finally
libthdmi.a.
> Which library should I be linking in? Thanks.
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
I had to include " -G -bexpall -bnoentry" in my link line for it to work so all is good. Thanks!
John C.: You forgot to compile and link to a shared library. Your
compiler command is trying to create an executable which requires all
identifiers to be resolved (at least with a shared library place holder) at
link time. Don't remember what the flag is for AIX's xlc though.
Art
Art S. Kagel
Advanced DataTools (www.advancedatatools.com)
Blog: http://informix-myview.blogspot.com/
Disclaimer: Please keep in mind that my own opinions are my own opinions
and do not reflect on my employer, Advanced DataTools, the IIUG, nor any
other organization with which I am associated either explicitly,
implicitly, or by inference. Neither do those opinions reflect those of
other individuals affiliated with any entity with which I am affiliated nor
those of the entities themselves.
On Thu, Apr 18, 2013 at 1:53 PM, John Miller iii <miller3@us.ibm.com> wrote:
> I believe the problem is with the linking.
>
> These functions are defined in "oninit" and will be resolved once the
> shared library is loaded. You just need to tell the linker to look for
> them later.
>
> John F. Miller III
> STSM, Lead Architect
> miller3@us.ibm.com
> 503-747-1366
> IBM Informix Dynamic Server (IDS)
>
> ids-bounces@iiug.org wrote on 04/18/2013 07:34:54 AM:
>
> > From: "JOHN CALLICOTTE" <john.callicotte@ottawa.edu>
> > To: ids@iiug.org,
> > Date: 04/18/2013 07:41 AM
> > Subject: Re: External C functions [30108]
> > Sent by: ids-bounces@iiug.org
> >
> > The jfm_return example worked great, but I can't get the jfm_upshiftto
> link.
> > I get:
> >
> > xlc -q64 -qmkshrobj -o jfm_upshift.so jfm_upshift.o
> > -L/home/carsids/callj/lib/common -lcommon -lc -L/opt/informix/lib/dmi
> -lthdmi
> > ld: 0711-317 ERROR: Undefined symbol: .mi_switch_mem_duration
> > ld: 0711-317 ERROR: Undefined symbol: .mi_lvarchar_to_string
> > ld: 0711-317 ERROR: Undefined symbol: .rupshift
> > ld: 0711-317 ERROR: Undefined symbol: .mi_string_to_lvarchar
> > ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
> > information.
> > make: *** [jfm_upshift.so] Error 8
> >
> > This is on AIX 6.1. I tried the libdmi.a, libifdmi.a, and finally
> libthdmi.a.
> > Which library should I be linking in? Thanks.
> >
> >
> >
>
>
>
*******************************************************************************
>
> > Forum Note: Use "Reply" to post a response in the discussion forum.
> >
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--089e01228d68c0e39c04daa6c26f