Subject RE: [Firebird-Java] Firebird embedded on Linux - success
Author Ryan Baldwin
Hi Nikolay,

>1. Compiling entrypoints.cpp -
>method JNIEXPORT jbyteArray JNICALL
Java_org_firebirdsql_ngds_GDS_1Impl_native_1isc_1blob_1info
>There is a bug in line 937 -> char* resultBuffer =
(char*)_alloca(jBufferLength); <-
>There is no such method. Since you can blame me in everything, except being
C (C++)developer I >>
>simply changed this line to make the char* to some string (with my ego it
was my name).
>I suppose _alloca is in some .h file but ....

This is a mistake I made while implementing this method. It should read
'alloca' rather then '_alloca'. alloca is then defined in platform.h
appropriatly. I will correct this in CVS today - but if you make that
replacement it should work better.

>root@localhost firebird2]# Exception in thread "main"
java.lang.UnsatisfiedLinkError: >/opt//jdk1.4/jre/lib/i386/libjaybird.so:
/opt/jdk1.4/jre/lib/i386/libjaybird.so: undefined symbol:
>>_ZTVN10__cxxabiv117__class_type_infoE
> at java.lang.ClassLoader$NativeLibrary.load(Native Method)
> at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1473)
> at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1389)
> at java.lang.Runtime.loadLibrary0(Runtime.java:788)
> at java.lang.System.loadLibrary(System.java:832)
> at org.firebirdsql.ngds.GDS_Impl.<init>(GDS_Impl.java:53)
>
>
>When i ldd-ed the libjaybird.so I saw this
>[root@localhost libr]# ldd -r /usr/lib/libjaybird.so
> libdl.so.2 => /lib/libdl.so.2 (0x40037000)
> libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
> /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
>undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE
(/usr/lib/libjaybird.so)
>undefined symbol: __gxx_personality_v0 (/usr/lib/libjaybird.so)
>undefined symbol: _ZTISt9bad_alloc (/usr/lib/libjaybird.so)
>undefined symbol: _Znaj (/usr/lib/libjaybird.so)
>undefined symbol: _ZdlPv (/usr/lib/libjaybird.so)
>undefined symbol: __cxa_end_catch (/usr/lib/libjaybird.so)
>undefined symbol: _Unwind_Resume (/usr/lib/libjaybird.so)
>undefined symbol: __cxa_throw (/usr/lib/libjaybird.so)
>undefined symbol: _ZdaPv (/usr/lib/libjaybird.so)
>undefined symbol: __cxa_begin_catch (/usr/lib/libjaybird.so)
>undefined symbol: __cxa_allocate_exception (/usr/lib/libjaybird.so)
>
>I searched for those symbols and I found them in libfbembedded.so
>
>At this point the final solution was simple (coping libfbembedded.so to
libfbclient.so)
>LD_PRELOAD libfbcliend.so java -cp <my_classes> <main_method>
>
>Everything wokrs just fine on my apps and tests excpet BLOBLS ofcourse :)
>Actually i modified java.library.path (well this time using path.seprator
instead of ";")
>The problem is that I played with LD_LIBRARY_PATH and java.library.path but
it was 5am in the
>morning, so I am not 100% sure which solutuon works, however I am 95% sure
that java.library.path is >the right one.

These symbols look like they are probarbly part of the c++ runtime library.
I dont know what the c++ runtime library is called for linux but ensuring
libjaybird.so is linked with the correct c++ runtime I would guess should
correct this problem.

>Since libjaybird is wrapper to libfbembedded why not link to it?

libjaybird links with the firebird client library using what in microsoft
terminology is called explicit dynamic linking. This is where it loads the
dll explicitly by name and then resolves entrypoints manually(see
FBBinings). This allows it more control over which dll is loaded and could
allow it too behave differntly depending on which entrypoints it finds on
the dll allowing it to in theory fail gracefully for missing features in
older versions.

The alternitive of linking staticly with the firebird client libraries
static import library would be whats refered too as implicit dynamic
linking - the static import library takes care of loading the dll and
resolving entrypoints for us - making it potentially more straightforward to
make use of the functionality within a dll - but taking away the advantages
described above. For example if we where too do this to make use of both
embedded server and type 2 mode on windows we would either need two
different jaybird.dll's(linked against different static import libraries) -
or force the user to rename fbembed.dll to use it.

>Yesterday I had a nasty problem with fbembedded on Windows. MSVC60 Depends
tool shows that
>fbembedded (fbclient) depends only on msvcrt.dll but when I deployed the
app on tests machines which >does not have any additional software installed
I saw that msvcp60.dll is required also (which was a >difficult to trace
problem, my first instalation was on win9x machine, which threw an
exception, >
>win2k machine pop-uped a screen which informed me about missed dll but 2
hours later... :(

Their has been some discussion regarding this in fb-support and
fb-development. There are some issues. Perhaps search the archives of these
forums for more details.

>Can some one guide me a little with JUnit tetst for firebird so I can
rework them to run against
>embedded firebird.

What problems do you get with running the target in the ant build script for
running the tests against the embedded server ?

>What else can I do to help?

If you could detail the changes you have made to get this running under
linux we make appropriate changes in CVS version so it can checkout too and
build/run on linux as easily as it does on windows/solaris(or did until the
_alloca mistake). (Yipee linux support in jaybird native !)

I hope this is of help.

Thanks
Ryan



-----Original Message-----
From: Nikolay Ivanchev [mailto:nivanchev@...]
Sent: 04 November 2003 08:46
To: JayBird
Subject: [Firebird-Java] Firebird embedded on Linux - success


Early this morning I managed to run it finaly.
Here are the problems which I encounter
1. Compiling entrypoints.cpp -
method JNIEXPORT jbyteArray JNICALL
Java_org_firebirdsql_ngds_GDS_1Impl_native_1isc_1blob_1info
There is a bug in line 937 -> char* resultBuffer =
(char*)_alloca(jBufferLength); <-
There is no such method. Since you can blame me in everything, except being
C (C++)developer I simply changed this line to make the char* to some string
(with my ego it was my name).
I suppose _alloca is in some .h file but ....

2. After compiling libjaybird.so is not linked to libfbembedded so when I
tried to run sample app it returned to me:

root@localhost firebird2]# Exception in thread "main"
java.lang.UnsatisfiedLinkError: /opt//jdk1.4/jre/lib/i386/libjaybird.so:
/opt/jdk1.4/jre/lib/i386/libjaybird.so: undefined symbol:
_ZTVN10__cxxabiv117__class_type_infoE
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1473)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1389)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:832)
at org.firebirdsql.ngds.GDS_Impl.<init>(GDS_Impl.java:53)


When i ldd-ed the libjaybird.so I saw this
[root@localhost libr]# ldd -r /usr/lib/libjaybird.so
libdl.so.2 => /lib/libdl.so.2 (0x40037000)
libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE
(/usr/lib/libjaybird.so)
undefined symbol: __gxx_personality_v0 (/usr/lib/libjaybird.so)
undefined symbol: _ZTISt9bad_alloc (/usr/lib/libjaybird.so)
undefined symbol: _Znaj (/usr/lib/libjaybird.so)
undefined symbol: _ZdlPv (/usr/lib/libjaybird.so)
undefined symbol: __cxa_end_catch (/usr/lib/libjaybird.so)
undefined symbol: _Unwind_Resume (/usr/lib/libjaybird.so)
undefined symbol: __cxa_throw (/usr/lib/libjaybird.so)
undefined symbol: _ZdaPv (/usr/lib/libjaybird.so)
undefined symbol: __cxa_begin_catch (/usr/lib/libjaybird.so)
undefined symbol: __cxa_allocate_exception (/usr/lib/libjaybird.so)

I searched for those symbols and I found them in libfbembedded.so

At this point the final solution was simple (coping libfbembedded.so to
libfbclient.so)
LD_PRELOAD libfbcliend.so java -cp <my_classes> <main_method>

Everything wokrs just fine on my apps and tests excpet BLOBLS ofcourse :)
Actually i modified java.library.path (well this time using path.seprator
instead of ";")
The problem is that I played with LD_LIBRARY_PATH and java.library.path but
it was 5am in the morning, so I am not 100% sure which solutuon works,
however I am 95% sure that java.library.path is the right one.

So I have several questions now:
LD_PRELOAD is not suitable for running embedded firebird with java course
IDE's refuse to start. I know I can use type4 drivers for development, but I
really like to develop in enviroment much closer to real situation.

Since libjaybird is wrapper to libfbembedded why not link to it?

Yesterday I had a nasty problem with fbembedded on Windows. MSVC60 Depends
tool shows that fbembedded (fbclient) depends only on msvcrt.dll but when I
deployed the app on tests machines which does not have any additional
software installed I saw that msvcp60.dll is required also (which was a
difficult to trace problem, my first instalation was on win9x machine, which
threw an exception, win2k machine pop-uped a screen which informed me about
missed dll but 2 hours later... :(
I added /D_STATIC_CPPLIB as a compiler directive but didn't helped. How can
work out this situatuon?

Can some one fix the bug in entrypoints.cpp so I can test against BLOB's?
Can some one guide me a little with JUnit tetst for firebird so I can rework
them to run against embedded firebird. I suppose linking to fbclient will be
required. (well I bought used copy of Java tools for extreme programming, so
in a week or so I will learn log4j, ant and JUnit).
What else can I do to help?

Regards,
Nikolay Ivanchev






Yahoo! Groups Sponsor



To unsubscribe from this group, send an email to:
Firebird-Java-unsubscribe@yahoogroups.com



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.