1. Trouble wrapping a dll
- Posted by ChrisB (moderator) Aug 21, 2010
- 1275 views
Hi
I'm trying to wrap the ezwidgets library
All the C examples work as compiled,
My initial experiment to get the library wrapped is
include dll.e include get.e include misc.e include machine.e --open the library global atom EZ EZ = open_dll("libEZ.so") ? EZ if EZ < 1 then puts(1, "Library open failed!\n") ? 1/0 end if ------------------------------------------------------------------------------ --EZ_Widget functions and procedures ------------------------------------------------------------------------------ constant xEZ_Initialize = define_c_proc(EZ, "EZ_Initialize", {C_INT, C_POINTER, C_INT}), xEZ_Shutdown = define_c_proc(EZ, "EZ_Shutdown", {}) ------------------------------------------------------------------------------ puts(1, "EZ_Initialize Handle value ") ? xEZ_Initialize global procedure EZ_Initialize(atom argc, sequence arguments, atom opengl) ------------------------------------------------------------------------------ atom argv, VOID, pargv pargv = allocate_string(arguments) c_proc(xEZ_Initialize, {argc, pargv, opengl}) --c_proc(xEZ_Initialize, {argc, argv, opengl}) end procedure ------------------------------------------------------------------------------ puts(1, "Shutdown handle ") ? xEZ_Shutdown global procedure EZ_Shutdown() ------------------------------------------------------------------------------ c_proc(xEZ_Shutdown, {}) end procedure --initialize ezwidgets - checks wrapping EZ_Initialize(0, {}, 0) --create widgets --EZ_EventMainLoop() --EZ_Shutdown() -- this, run, produces -- 168318704 -- EZ_Initialize Handle value 8 -- Shutdown handle 9 -- eui: symbol lookup error: /usr/lib/libEZ.so: undefined symbol: XrmInitialize -- Press any key to continue...
As you can see, linking the lib and the functions produces some valid handles, but why is eui producing a symbol lookup error?
I have checked with ldd, and libEZ.so has no missing dependencies. XrmInitialize seems to be an X library function, called from within libEZ.
Any ideas anyone?
Chris
2. Re: Trouble wrapping a dll
- Posted by mattlewis (admin) Aug 21, 2010
- 1250 views
As you can see, linking the lib and the functions produces some valid handles, but why is eui producing a symbol lookup error?
I have checked with ldd, and libEZ.so has no missing dependencies. XrmInitialize seems to be an X library function, called from within libEZ.
Any ideas anyone?
Sounds like there is some name mangling going on. Use nm to get information on the exported symbols. For C code, I think the default is to add an underscore before the exported name. The euphoria translator overrides this to leave undecorated names when it builds a shared library.
Matt
3. Re: Trouble wrapping a dll
- Posted by ChrisB (moderator) Aug 21, 2010
- 1265 views
Hi
nm on libEZ.so says that XrmInitialize is undefined ( 'U' in the type column)
adding an underscore to EZ_initialize produces a -1 Handle number
Chris
4. Re: Trouble wrapping a dll
- Posted by ne1uno Aug 21, 2010
- 1240 views
Hi
nm on libEZ.so says that XrmInitialize is undefined ( 'U' in the type column)
ld --output-def some.def ./some.sothat works with dll's to produce a def file that lists all the export routines
5. Re: Trouble wrapping a dll
- Posted by ChrisB (moderator) Aug 22, 2010
- 1212 views
Hi
Neither ld or ldd have a output-def command line option.
eui: symbol lookup error: /usr/lib/libEZ.so: undefined symbol: XrmInitialize
Can anyone tell me why eui is giving the symbol lookup error, when the program is not calling XrmInitialize, it is in libEZ.so that is calling it? Does eui have to link all the functions within the .so? If so, I have checked for the presence of XrmInitialise within libX11.so, and it is definitely there.
Chris
6. Re: Trouble wrapping a dll
- Posted by mattlewis (admin) Aug 23, 2010
- 1103 views
Hi
Neither ld or ldd have a output-def command line option.
eui: symbol lookup error: /usr/lib/libEZ.so: undefined symbol: XrmInitialize
Can anyone tell me why eui is giving the symbol lookup error, when the program is not calling XrmInitialize, it is in libEZ.so that is calling it? Does eui have to link all the functions within the .so? If so, I have checked for the presence of XrmInitialise within libX11.so, and it is definitely there.
Very strange. Did you build libEZ.so yourself? Where did you get it?
Matt
7. Re: Trouble wrapping a dll
- Posted by ChrisB (moderator) Aug 23, 2010
- 1149 views
Hi Matt got the library from here
http://www.ma.utexas.edu/users/mzou/EZWGL/
Built it myself, using stock xubuntu 8.(something), and the demos and examples, and installed as a shared library.
All the c examples and demos work.
Yes it is strange - and frustrating!
Of course, it could be the library, and the build setup, one idea would be for someone else to build it, email it to me, and see if it works (or doesn't) still. The other thing that I have thought of is that in some way the paths aren't correct for eui - I have put symlinks in the paths to see if that helps, but to no avail.
Chris
8. Re: Trouble wrapping a dll
- Posted by mattlewis (admin) Aug 23, 2010
- 1152 views
Of course, it could be the library, and the build setup, one idea would be for someone else to build it, email it to me, and see if it works (or doesn't) still. The other thing that I have thought of is that in some way the paths aren't correct for eui - I have put symlinks in the paths to see if that helps, but to no avail.
OK, I see what happened. He never links libX11.so. There is a variable to do so, but he never actually uses it:
XLIB = -lXext -lX11 -lX11
So, linking those libs seems to get past the undefined symbol issue:
open_dll("libX11.so") open_dll("libXext.so")
But then I get a machine-level exception in the call to EZ_Initialize. I haven't looked any farther than that.
Matt
9. Re: Trouble wrapping a dll
- Posted by ChrisB (moderator) Aug 23, 2010
- 1098 views
Hi
Thanks for looking Matt.
Chris