esql pam module - undefined symbol: sqlca
Posted in 2013
A developer building a PAM shared module in ESQL/C hit "dlopen: undefined symbol: sqlca" because the host program wasn't linked with ESQL libraries. The advice: let esql do the linking, use `esql -libs` to get the needed library list (lifsql, lifasf, lifgen, lifos, lifgls, checkapi.o, etc.) when linking with gcc/ld, build with INFORMIXC="cc -shared" esql, and ensure LD_LIBRARY_PATH covers $INFORMIXDIR/lib and lib/esql. That fixed the link problem. A follow-on -23111 GLS locale error (library not finding $INFORMIXDIR/gls) was never solved directly; the author instead had the PAM module call a separate inetd-based process to make the database connection.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Hi, I'm attempting to make a pam module that uses esql to read a table from an Informix table and authenticate against it. I have a test application that I'm using to test out the call into the pam layer. If I compile the pam shared object and the test app using esql, everything seems to work as expected. Unfortunately, the program that will be using this pam module is not compiled with esql, and when it attempts to load the module I get this error in the pam debug: PAM unable to dlopen(<file name removed.so>): undefined symbol: sqlca So, I changed the code from a shared object to an executable for testing, and changed the compiler from esql to cc, since the calling code doesn't pull in esql libraries. As expected, I got compile errors complaining about an undefined reference to sqlca. I tried pulling in Informix/lib/esql/libsql.a, but that creates pages of other undefined references. Does somebody happen to have a listing of the library dependencies, or an example of how to link in esql libraries with cc/ld? -Justin
Just use the esql script to perform the linking, it will include the needed libraries automatically. 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, Jun 20, 2013 at 2:46 PM, Justin Killen < jkillen@allamericanasphalt.com> wrote: > Hi, > > I'm attempting to make a pam module that uses esql to read a table from an > Informix table and authenticate against it. I have a test application that > I'm > using to test out the call into the pam layer. If I compile the pam shared > object and the test app using esql, everything seems to work as expected. > Unfortunately, the program that will be using this pam module is not > compiled > with esql, and when it attempts to load the module I get this error in the > pam > debug: > > PAM unable to dlopen(<file name removed.so>): undefined symbol: sqlca > > So, I changed the code from a shared object to an executable for testing, > and > changed the compiler from esql to cc, since the calling code doesn't pull > in > esql libraries. As expected, I got compile errors complaining about an > undefined reference to sqlca. I tried pulling in > Informix/lib/esql/libsql.a, > but that creates pages of other undefined references. > > Does somebody happen to have a listing of the library dependencies, or an > example of how to link in esql libraries with cc/ld? > -Justin > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --001a11c356e2a5eba504df9a7b4c
On 20/06/13 19:46, Justin Killen wrote: > Hi, > > I'm attempting to make a pam module that uses esql to read a table from an > Informix table and authenticate against it. I have a test application that I'm > using to test out the call into the pam layer. If I compile the pam shared > object and the test app using esql, everything seems to work as expected. > Unfortunately, the program that will be using this pam module is not compiled > with esql, and when it attempts to load the module I get this error in the pam > debug: > > PAM unable to dlopen(<file name removed.so>): undefined symbol: sqlca > > So, I changed the code from a shared object to an executable for testing, and > changed the compiler from esql to cc, since the calling code doesn't pull in > esql libraries. As expected, I got compile errors complaining about an > undefined reference to sqlca. I tried pulling in Informix/lib/esql/libsql.a, > but that creates pages of other undefined references. > > Does somebody happen to have a listing of the library dependencies, or an > example of how to link in esql libraries with cc/ld? > -Justin I do write esql/c stuff that gets loaded as a shared library by programs not compiled with esql and it works quite happily. Needless to say, even though the program does not know about informix, you still have to have a proper informix environment set, including LD_LIBRARY_PATH pointing to $INFORMIXDIR/lib:$INFORMIXDIR/lib/esql. In the worse case, build the shared object in static mode (not that I ever had a need to do that). -- Ciao, Marco ______________________________________________________________________________ Marco Greco /UK /IBM Standard disclaimers apply! Structured Query Scripting Language http://www.4glworks.com/sqsl.htm 4glworks http://www.4glworks.com Informix on Linux http://www.4glworks.com/ifmxlinux.htm
Oh, I forgot, you can also use esql to find out what libraries need to be linked into your application if you want to link it using just ld (forgot I used to use this feature): esql -libs-lifsql -lifasf -lifgen -lifos -lifgls -lpthread -lm -ldl -lcrypt /opt/informix/infmx/lib/esql/checkapi.o -lifglx 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, Jun 20, 2013 at 3:42 PM, Marco Greco <marco@4glworks.com> wrote: > On 20/06/13 19:46, Justin Killen wrote: > > Hi, > > > > I'm attempting to make a pam module that uses esql to read a table from > an > > Informix table and authenticate against it. I have a test application > that > I'm > > using to test out the call into the pam layer. If I compile the pam > shared > > object and the test app using esql, everything seems to work as expected. > > Unfortunately, the program that will be using this pam module is not > compiled > > with esql, and when it attempts to load the module I get this error in > the > pam > > debug: > > > > PAM unable to dlopen(<file name removed.so>): undefined symbol: sqlca > > > > So, I changed the code from a shared object to an executable for testing, > and > > changed the compiler from esql to cc, since the calling code doesn't > pull in > > esql libraries. As expected, I got compile errors complaining about an > > undefined reference to sqlca. I tried pulling in > Informix/lib/esql/libsql.a, > > but that creates pages of other undefined references. > > > > Does somebody happen to have a listing of the library dependencies, or an > > example of how to link in esql libraries with cc/ld? > > -Justin > > I do write esql/c stuff that gets loaded as a shared library by programs > not > compiled with esql and it works quite happily. > Needless to say, even though the program does not know about informix, you > still have to have a proper informix environment set, including > LD_LIBRARY_PATH pointing to $INFORMIXDIR/lib:$INFORMIXDIR/lib/esql. > In the worse case, build the shared object in static mode (not that I ever > had > a need to do that). > > -- > Ciao, > Marco > > ______________________________________________________________________________ > Marco Greco /UK /IBM Standard disclaimers apply! > > Structured Query Scripting Language http://www.4glworks.com/sqsl.htm > 4glworks http://www.4glworks.com > Informix on Linux http://www.4glworks.com/ifmxlinux.htm > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --001a11c371220ffbee04df9baf2e
After reviewing the comments and looking at the Makefile, it looks like I compiled with esql but then linked with ld. I couldn't find a command line option for esql to create a shared object, but I did find this reference from IBM: http://publib.boulder.ibm.com/infocenter/idshelp/v117/index.jsp?topic=%2Fcom.ibm .gen_busug.doc%2Fc_fgl_CExtensions_005.htm esql -c -I$FGLDIR/include myext.ec gcc -c -I$FGLDIR/include -fPIC cinterf.c gcc -shared -o myext.so myext.o cinterf.o -L$FGLDIR/lib -lfgl \\\\ -L$INFORMIXDIR/lib -L$INFORMIXDIR/lib/esql `esql -libs` I tried that (minus the 4gl libs) and that works as expected. Thanks for the help. -Justin -----Original Message----- From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Marco Greco Sent: Thursday, June 20, 2013 12:43 PM To: ids@iiug.org Subject: Re: esql pam module - undefined symbol: sqlca [30586] On 20/06/13 19:46, Justin Killen wrote: > Hi, > > I'm attempting to make a pam module that uses esql to read a table from an > Informix table and authenticate against it. I have a test application that I'm > using to test out the call into the pam layer. If I compile the pam shared > object and the test app using esql, everything seems to work as expected. > Unfortunately, the program that will be using this pam module is not compiled > with esql, and when it attempts to load the module I get this error in the pam > debug: > > PAM unable to dlopen(<file name removed.so>): undefined symbol: sqlca > > So, I changed the code from a shared object to an executable for testing, and > changed the compiler from esql to cc, since the calling code doesn't pull in > esql libraries. As expected, I got compile errors complaining about an > undefined reference to sqlca. I tried pulling in Informix/lib/esql/libsql.a, > but that creates pages of other undefined references. > > Does somebody happen to have a listing of the library dependencies, or an > example of how to link in esql libraries with cc/ld? > -Justin I do write esql/c stuff that gets loaded as a shared library by programs not compiled with esql and it works quite happily. Needless to say, even though the program does not know about informix, you still have to have a proper informix environment set, including LD_LIBRARY_PATH pointing to $INFORMIXDIR/lib:$INFORMIXDIR/lib/esql. In the worse case, build the shared object in static mode (not that I ever had a need to do that). -- Ciao, Marco ______________________________________________________________________________ Marco Greco /UK /IBM Standard disclaimers apply! Structured Query Scripting Language http://www.4glworks.com/sqsl.htm 4glworks http://www.4glworks.com Informix on Linux http://www.4glworks.com/ifmxlinux.htm ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum.
Thanks Art - that's what I ended up doing and it works great. -Justin -----Original Message----- From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Art Kagel Sent: Thursday, June 20, 2013 1:21 PM To: ids@iiug.org Subject: Re: esql pam module - undefined symbol: sqlca [30587] Oh, I forgot, you can also use esql to find out what libraries need to be linked into your application if you want to link it using just ld (forgot I used to use this feature): esql -libs-lifsql -lifasf -lifgen -lifos -lifgls -lpthread -lm -ldl -lcrypt /opt/informix/infmx/lib/esql/checkapi.o -lifglx 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, Jun 20, 2013 at 3:42 PM, Marco Greco <marco@4glworks.com> wrote: > On 20/06/13 19:46, Justin Killen wrote: > > Hi, > > > > I'm attempting to make a pam module that uses esql to read a table from > an > > Informix table and authenticate against it. I have a test application > that > I'm > > using to test out the call into the pam layer. If I compile the pam > shared > > object and the test app using esql, everything seems to work as expected. > > Unfortunately, the program that will be using this pam module is not > compiled > > with esql, and when it attempts to load the module I get this error in > the > pam > > debug: > > > > PAM unable to dlopen(<file name removed.so>): undefined symbol: sqlca > > > > So, I changed the code from a shared object to an executable for testing, > and > > changed the compiler from esql to cc, since the calling code doesn't > pull in > > esql libraries. As expected, I got compile errors complaining about an > > undefined reference to sqlca. I tried pulling in > Informix/lib/esql/libsql.a, > > but that creates pages of other undefined references. > > > > Does somebody happen to have a listing of the library dependencies, or an > > example of how to link in esql libraries with cc/ld? > > -Justin > > I do write esql/c stuff that gets loaded as a shared library by programs > not > compiled with esql and it works quite happily. > Needless to say, even though the program does not know about informix, you > still have to have a proper informix environment set, including > LD_LIBRARY_PATH pointing to $INFORMIXDIR/lib:$INFORMIXDIR/lib/esql. > In the worse case, build the shared object in static mode (not that I ever > had > a need to do that). > > -- > Ciao, > Marco > > ______________________________________________________________________________ > Marco Greco /UK /IBM Standard disclaimers apply! > > Structured Query Scripting Language http://www.4glworks.com/sqsl.htm > 4glworks http://www.4glworks.com > Informix on Linux http://www.4glworks.com/ifmxlinux.htm > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --001a11c371220ffbee04df9baf2e ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum.
On 20/06/13 21:24, Justin Killen wrote:
> After reviewing the comments and looking at the Makefile, it looks like I
> compiled with esql but then linked with ld. I couldn't find a command line
> option for esql to create a shared object, but I did find this reference from
> IBM:
>
>
http://publib.boulder.ibm.com/infocenter/idshelp/v117/index.jsp?topic=%2Fcom.ibm
.gen_busug.doc%2Fc_fgl_CExtensions_005.htm
>
> esql -c -I$FGLDIR/include myext.ec
> gcc -c -I$FGLDIR/include -fPIC cinterf.c
> gcc -shared -o myext.so myext.o cinterf.o -L$FGLDIR/lib -lfgl \\\\
>
> -L$INFORMIXDIR/lib -L$INFORMIXDIR/lib/esql `esql -libs`
>
> I tried that (minus the 4gl libs) and that works as expected.
>
> Thanks for the help.
>
> -Justin
> -----Original Message-----
> From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Marco
> Greco
> Sent: Thursday, June 20, 2013 12:43 PM
> To: ids@iiug.org
> Subject: Re: esql pam module - undefined symbol: sqlca [30586]
>
> On 20/06/13 19:46, Justin Killen wrote:
>> Hi,
>>
>> I'm attempting to make a pam module that uses esql to read a table from an
>> Informix table and authenticate against it. I have a test application that
> I'm
>> using to test out the call into the pam layer. If I compile the pam shared
>> object and the test app using esql, everything seems to work as expected.
>> Unfortunately, the program that will be using this pam module is not
> compiled
>> with esql, and when it attempts to load the module I get this error in the
> pam
>> debug:
>>
>> PAM unable to dlopen(<file name removed.so>): undefined symbol: sqlca
>>
>> So, I changed the code from a shared object to an executable for testing,
> and
>> changed the compiler from esql to cc, since the calling code doesn't pull in
>> esql libraries. As expected, I got compile errors complaining about an
>> undefined reference to sqlca. I tried pulling in Informix/lib/esql/libsql.a,
>> but that creates pages of other undefined references.
>>
>> Does somebody happen to have a listing of the library dependencies, or an
>> example of how to link in esql libraries with cc/ld?
>> -Justin
>
> I do write esql/c stuff that gets loaded as a shared library by programs not
> compiled with esql and it works quite happily.
> Needless to say, even though the program does not know about informix, you
> still have to have a proper informix environment set, including
> LD_LIBRARY_PATH pointing to $INFORMIXDIR/lib:$INFORMIXDIR/lib/esql.
> In the worse case, build the shared object in static mode (not that I ever
had
> a need to do that).
>
FYI for next time, here's
INFORMIXC="cc -G" esql file.o -o file.so
or
INFORMIXC="cc -shared" esql file.o -o file.so
with gcc
--
Ciao,
Marco
______________________________________________________________________________
Marco Greco /UK /IBM Standard disclaimers apply!
Structured Query Scripting Language http://www.4glworks.com/sqsl.htm
4glworks http://www.4glworks.com
Informix on Linux http://www.4glworks.com/ifmxlinux.htm
Now that it's all built and loading within the engine, I attempted to run a
select query and I'm getting an error with SQL code -23111. This turns out to
be:
-23111 Internal error. Illegal argument for locale initialization.
An internal function used an illegal argument while it was initializing
the GLS structures. The arguments can only be one of the following:
FE_PROC, BE_PROC, or SESS_PROC. If the error recurs, see your
Administrator's Guide or Reference to acquire additional diagnostics and
contact IBM Technical Support with the diagnostic information.
The only hit on google I could find for a fix for that error was setting the
DB_LOCALE environment variable, but that doesn't seem to fix it.
Any ideas on what I can do to fix this?
-Justin
-----Original Message-----
From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Marco
Greco
Sent: Thursday, June 20, 2013 1:32 PM
To: ids@iiug.org
Subject: Re: esql pam module - undefined symbol: sqlca [30590]
On 20/06/13 21:24, Justin Killen wrote:
> After reviewing the comments and looking at the Makefile, it looks like I
> compiled with esql but then linked with ld. I couldn't find a command line
> option for esql to create a shared object, but I did find this reference
from
> IBM:
>
>
http://publib.boulder.ibm.com/infocenter/idshelp/v117/index.jsp?topic=%2Fcom.ibm
.gen_busug.doc%2Fc_fgl_CExtensions_005.htm
>
> esql -c -I$FGLDIR/include myext.ec
> gcc -c -I$FGLDIR/include -fPIC cinterf.c
> gcc -shared -o myext.so myext.o cinterf.o -L$FGLDIR/lib -lfgl \\\\
>
> -L$INFORMIXDIR/lib -L$INFORMIXDIR/lib/esql `esql -libs`
>
> I tried that (minus the 4gl libs) and that works as expected.
>
> Thanks for the help.
>
> -Justin
> -----Original Message-----
> From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Marco
> Greco
> Sent: Thursday, June 20, 2013 12:43 PM
> To: ids@iiug.org
> Subject: Re: esql pam module - undefined symbol: sqlca [30586]
>
> On 20/06/13 19:46, Justin Killen wrote:
>> Hi,
>>
>> I'm attempting to make a pam module that uses esql to read a table from an
>> Informix table and authenticate against it. I have a test application that
> I'm
>> using to test out the call into the pam layer. If I compile the pam shared
>> object and the test app using esql, everything seems to work as expected.
>> Unfortunately, the program that will be using this pam module is not
> compiled
>> with esql, and when it attempts to load the module I get this error in the
> pam
>> debug:
>>
>> PAM unable to dlopen(<file name removed.so>): undefined symbol: sqlca
>>
>> So, I changed the code from a shared object to an executable for testing,
> and
>> changed the compiler from esql to cc, since the calling code doesn't pull
in
>> esql libraries. As expected, I got compile errors complaining about an
>> undefined reference to sqlca. I tried pulling in
Informix/lib/esql/libsql.a,
>> but that creates pages of other undefined references.
>>
>> Does somebody happen to have a listing of the library dependencies, or an
>> example of how to link in esql libraries with cc/ld?
>> -Justin
>
> I do write esql/c stuff that gets loaded as a shared library by programs not
> compiled with esql and it works quite happily.
> Needless to say, even though the program does not know about informix, you
> still have to have a proper informix environment set, including
> LD_LIBRARY_PATH pointing to $INFORMIXDIR/lib:$INFORMIXDIR/lib/esql.
> In the worse case, build the shared object in static mode (not that I ever
had
> a need to do that).
>
FYI for next time, here's
INFORMIXC="cc -G" esql file.o -o file.so
or
INFORMIXC="cc -shared" esql file.o -o file.so
with gcc
--
Ciao,
Marco
______________________________________________________________________________
Marco Greco /UK /IBM Standard disclaimers apply!
Structured Query Scripting Language http://www.4glworks.com/sqsl.htm
4glworks http://www.4glworks.com
Informix on Linux http://www.4glworks.com/ifmxlinux.htm
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
On 21/06/13 00:58, Justin Killen wrote: > Now that it's all built and loading within the engine, I attempted to run a > select query and I'm getting an error with SQL code -23111. This turns out to > be: > > -23111 Internal error. Illegal argument for locale initialization. > > An internal function used an illegal argument while it was initializing > the GLS structures. The arguments can only be one of the following: > FE_PROC, BE_PROC, or SESS_PROC. If the error recurs, see your > Administrator's Guide or Reference to acquire additional diagnostics and > contact IBM Technical Support with the diagnostic information. > > The only hit on google I could find for a fix for that error was setting the > DB_LOCALE environment variable, but that doesn't seem to fix it. > > Any ideas on what I can do to fix this? > > -Justin That looks like you shared library trying to initialize GLS from $INFORMIXDIR/gls but not finding it. If you truss / strace the application you will see what directories it is trying.... -- Ciao, Marco ______________________________________________________________________________ Marco Greco /UK /IBM Standard disclaimers apply! Structured Query Scripting Language http://www.4glworks.com/sqsl.htm 4glworks http://www.4glworks.com Informix on Linux http://www.4glworks.com/ifmxlinux.htm
The application calling the shared object is Informix via PAM. Ultimately, it seemed like a bad idea to have the server connect to itself within the same process, so I instead switched the PAM module to connect to a separate process which would then in turn do the client connection. I just did a simple inetd service, and it works as expected. It's not quite as fast, but it should be good enough for now, and I can always make it faster by changing it to a full-blown socket listener. -Justin -----Original Message----- From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Marco Greco Sent: Friday, June 21, 2013 6:58 AM To: ids@iiug.org Subject: Re: esql pam module - undefined symbol: sqlca [30597] On 21/06/13 00:58, Justin Killen wrote: > Now that it's all built and loading within the engine, I attempted to run a > select query and I'm getting an error with SQL code -23111. This turns out to > be: > > -23111 Internal error. Illegal argument for locale initialization. > > An internal function used an illegal argument while it was initializing > the GLS structures. The arguments can only be one of the following: > FE_PROC, BE_PROC, or SESS_PROC. If the error recurs, see your > Administrator's Guide or Reference to acquire additional diagnostics and > contact IBM Technical Support with the diagnostic information. > > The only hit on google I could find for a fix for that error was setting the > DB_LOCALE environment variable, but that doesn't seem to fix it. > > Any ideas on what I can do to fix this? > > -Justin That looks like you shared library trying to initialize GLS from $INFORMIXDIR/gls but not finding it. If you truss / strace the application you will see what directories it is trying.... -- Ciao, Marco ______________________________________________________________________________ Marco Greco /UK /IBM Standard disclaimers apply! Structured Query Scripting Language http://www.4glworks.com/sqsl.htm 4glworks http://www.4glworks.com Informix on Linux http://www.4glworks.com/ifmxlinux.htm ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum.