Board index » delphi » Udf with Linux & Interbase 6.1

Udf with Linux & Interbase 6.1

Linux RedHat 7.1
Interbase 6.01 Open Source

Hi,

I'm porting some udf functions from Windows to Linux. Now I'm only trying
with a couple of them and I have a problem.

Trying to use the udf (INUDF_Abs) I get:

<
Invalid request BLR at offset 59
function INUDF_ABS is not defined
module name or entrypoint could not be found
Statement: select inudf_abs(-1) from rdb$database

Quote

The library is written in C++ and I build it with a makefile like this:

<
INGlobals: INGlobals.o NumUdf.o Stringudf.o
    ld -o INGlobals INGlobals.o NumUdf.o Stringudf.o -shared -lgds
INGlobals.o: INGlobals.cpp
    g++ -c INGlobals.cpp
NumUdf.o: NumUdf.cpp
    g++ -c NumUdf.cpp
Stringudf.o: StringUdf.cpp
    g++ -c StringUdf.cpp

Quote

I moved the library I made (INGlobals) to /interbase_path/udf dir and I
updated the LD_LIBRARY_PATH too!

I can't understand if Interbase can't find the library or the function.
Maybe there's a name mismatch caused by the C++ name mangling, so I tried
with extern "c", but the compiler does not like the "c", and finally I kept
the extern (but without it it's the same).

It's my first linux library so maybe there's something as big as I'm new to
this enviroment!

Who can help me?

Thank You in advance
Massimiliano Trezzi

 

Re:Udf with Linux & Interbase 6.1


Quote
In article <3ae86f05_1@dnews>, Massimiliano Trezzi wrote:
> Linux RedHat 7.1
> Interbase 6.01 Open Source

> Hi,

> I'm porting some udf functions from Windows to Linux. Now I'm only trying
> with a couple of them and I have a problem.

> Trying to use the udf (INUDF_Abs) I get:

> <

I have a bunch that work in windows, linux and solaris...

I use gcc to compile them in linux.

hth

Robert Schieck (TeamB)
MER Systems Inc.
Inprise/Borland/InterBase Search Engine http://www.mers.com/searchsite.html

Re:Udf with Linux & Interbase 6.1


Hi Massimo!
I think that you have to add the parameter "-fpic" to the compiler command.
Something like this:
g++ -c -fpic INGlobals.cpp

By another side, in Unix/Linux remember the module name is case sensitive,
if you are creating a shared lib with the name "INGlobals", then in the
sentence DECLARE EXTERNAL FUNCTION, put the module
name as MODULE_NAME 'INGlobals'

See you!

@riel.

_________________________
Ariel Carn
Buenos Aires - ARGENTINA
e-mail: aca...@ciudad.com.ar

Quote
"Massimiliano Trezzi" <masst...@tin.it> wrote in message

news:3ae86f05_1@dnews...
Quote
> Linux RedHat 7.1
> Interbase 6.01 Open Source

> Hi,

> I'm porting some udf functions from Windows to Linux. Now I'm only trying
> with a couple of them and I have a problem.

> Trying to use the udf (INUDF_Abs) I get:

> <
> Invalid request BLR at offset 59
> function INUDF_ABS is not defined
> module name or entrypoint could not be found
> Statement: select inudf_abs(-1) from rdb$database

> The library is written in C++ and I build it with a makefile like this:

> <
> INGlobals: INGlobals.o NumUdf.o Stringudf.o
>     ld -o INGlobals INGlobals.o NumUdf.o Stringudf.o -shared -lgds
> INGlobals.o: INGlobals.cpp
>     g++ -c INGlobals.cpp
> NumUdf.o: NumUdf.cpp
>     g++ -c NumUdf.cpp
> Stringudf.o: StringUdf.cpp
>     g++ -c StringUdf.cpp

> I moved the library I made (INGlobals) to /interbase_path/udf dir and I
> updated the LD_LIBRARY_PATH too!

> I can't understand if Interbase can't find the library or the function.
> Maybe there's a name mismatch caused by the C++ name mangling, so I tried
> with extern "c", but the compiler does not like the "c", and finally I
kept
> the extern (but without it it's the same).

> It's my first linux library so maybe there's something as big as I'm new
to
> this enviroment!

> Who can help me?

> Thank You in advance
> Massimiliano Trezzi

Re:Udf with Linux & Interbase 6.1


Thank you Ariel,
I tried but It doesn't work.
The problem is in C++ name mangling: if I compile it as a C source, all it's
ok!
If I compile it as a C++ source the problem arise befause of his export
name.
I can see it with the "nm" utility: when I call it for the C library i get:
<
nm  INGlobals | grep INUDF
000002b0 T INUDF_Abs

Quote

for the C++ library
<
nm INGlobals | grep INUDF
000025a0 T INUDF_Abs__fpd

Quote

Now it's clear that the problem is the name of the exported function.
In Windows with Borland C++ I used extern "c"  but in Linux?

Thank you in advance,
Massimiliano Trezzi

"Ariel Carn" <aca...@ciudad.com.ar> ha scritto nel messaggio
news:9cap9v$6b6$1@linux.mers.com...

Quote
> Hi Massimo!
> I think that you have to add the parameter "-fpic" to the compiler
command.
> Something like this:
> g++ -c -fpic INGlobals.cpp

> By another side, in Unix/Linux remember the module name is case sensitive,
> if you are creating a shared lib with the name "INGlobals", then in the
> sentence DECLARE EXTERNAL FUNCTION, put the module
> name as MODULE_NAME 'INGlobals'

> See you!

> @riel.

> _________________________
> Ariel Carn
> Buenos Aires - ARGENTINA
> e-mail: aca...@ciudad.com.ar

Re:Udf with Linux & Interbase 6.1


New Episode:

I tried again with extern "C" using {} and the names are ok!
But now the library does not work.
If I use the C target all it's ok.
So now I know that Interbase finds the library, but if it's compiled with C
all it's ok, with C++ no!
Now "nm" give alwais the same result about INUDF_Abs.
What can I do?

Thank you in advance,
Massimiliano Trezzi

"Massimiliano Trezzi" <supp...@intesanet.com> ha scritto nel messaggio
news:3ae98dcf$1_2@dnews...

Quote
> Thank you Ariel,
> I tried but It doesn't work.
> The problem is in C++ name mangling: if I compile it as a C source, all
it's
> ok!
> If I compile it as a C++ source the problem arise befause of his export
> name.
> I can see it with the "nm" utility: when I call it for the C library i
get:
> <
> nm  INGlobals | grep INUDF
> 000002b0 T INUDF_Abs

> for the C++ library
> <
> nm INGlobals | grep INUDF
> 000025a0 T INUDF_Abs__fpd

> Now it's clear that the problem is the name of the exported function.
> In Windows with Borland C++ I used extern "c"  but in Linux?

> Thank you in advance,
> Massimiliano Trezzi

Other Threads