Using zlib and IDL 6.1 in a DLM [message #46756] |
Wed, 21 December 2005 10:13  |
Maurizio Tomasi
Messages: 7 Registered: December 2005
|
Junior Member |
|
|
Hello to everybody,
I am writing a huge IDL 6.1 program under OpenSUSE Linux 10.0 which
should call some C functions defined using a Dynamic Linked Module.
Those function are already written and use the GTK+ library. They work
fine, however PNG icons are not displayed and instead a "Fatal error in
PNG image file: zlib version error" message is printed (the dialog box
however opens and show a "X" where the image should have been placed).
After some thoughts, I found the problem lies in the fact that the IDL
libraries to be linked with my shared library already provide zlib
functions, but they are from zlib 1.1.4 (while my GTK+ libraries use 1.2.3).
The following test program shows what happens:
----------------------------------
#include <stdio.h>
#include <zlib.h>
int
main (void)
{
puts (zlibVersion ());
return 0;
}
----------------------------------
If I compile and run it, I get the following:
$ gcc -o test2 test2.c -lz
1.2.3
$
Now I modify it so that becomes a shared library:
----------------------------------
#include <stdio.h>
#include <zlib.h>
#include "idl_export.h"
IDL_VPTR
print_zlib_version (void)
{
puts (zlibVersion ());
return NULL;
}
----------------------------------
When I compile the shared library, I get the following:
----------------------------------
$ gcc -c -I/opt/idl/idl/external/include test.c -fPIC -DPIC -o test.o
$ gcc -o test.so -shared test.o -L/opt/idl/idl/bin/bin.linux.x86/ -lidl
$ idl
IDL Version 6.1 (linux x86 m32). (c) 2004, Research Systems, Inc.
Trial version expires on 31-dec-2005.
Licensed for personal use by INAF-Catania only.
All other use is strictly prohibited.
IDL> linkimage, 'PRINT_ZLIB_VERSION', 'test.so'
IDL> print_zlib_version
1.1.4
----------------------------------
My question is: how can I tell my DLM to use my zlib library instead of
the one provided by IDL?
Thank you very much,
Maurizio.
|
|
|
Re: Using zlib and IDL 6.1 in a DLM [message #46843 is a reply to message #46756] |
Tue, 27 December 2005 03:17  |
Maurizio Tomasi
Messages: 7 Registered: December 2005
|
Junior Member |
|
|
Karl wrote:
> IDL is overriding the definitions in the shared library. This is
> normal linux linker/loader behavior. To stop this from happening, use
> -Bsymbolic.
>
> I also found that I had to link the non-shared libz.
>
> So, the linker command that worked for me is:
>
> gcc -shared -o test.so test.o /usr/lib/libz.a -Wl,-Bsymbolic
> -L/tmp/idl/bin/bin.linux.x86 -lidl
It works!! Unfortunately, I discovered that I should recompile the GTK+
libraries in this way as well, in order to make my program work with
libpng. Well, at least now I am able to use the version of zlib I prefer
in my C code.
Thank you very much!
Maurizio.
|
|
|