Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using Kylix made SO library from non Kylix Applications

0 views
Skip to first unread message

Andrew Golubsky

unread,
Jul 2, 2001, 9:38:08 AM7/2/01
to
Hello
Please tell me what is wrong ?
when gnu C made application(it use so library made with kylix) terminates i
got
Segmentation Fault (core dumped) error
when i load this library from kylix application everything is ok.

application is very simple : dlopen , dlsym, dlclose
SO libary is also very simple and build with out packages.
platform is :Red Hat 6.2 with Kylix installed.
Thank you.


Rick Ross

unread,
Jul 2, 2001, 10:20:27 AM7/2/01
to
> Please tell me what is wrong ?
> when gnu C made application(it use so library made with kylix) terminates i
> got
> Segmentation Fault (core dumped) error
> when i load this library from kylix application everything is ok.

By default Pascal passes arguments using the register calling convention, C
does not. You probably have a mismatch between the Kylix routines and the C
routines. The easiest way around this mismatch is to explicity declare the
calling convention used, by adding the cdecl directive to the end of the
function declaration like this:

function MySoFunction(X, Y: integer): integer; cdecl;

cdecl is the default calling convention for C. For more information search the
help for cdecl or calling conventions

HTH

Rick

Andrew Golubsky

unread,
Jul 3, 2001, 2:17:57 AM7/3/01
to

Sorry , with calling convention everything is ok
I have this situation when i simply load and unload library , i do not call
any function from SO library
Once more : when program terminates i got > > Segmentation Fault (core
dumped) error


Rick Ross

unread,
Jul 3, 2001, 7:56:38 AM7/3/01
to
> Sorry , with calling convention everything is ok
> I have this situation when i simply load and unload library , i do not call
> any function from SO library
> Once more : when program terminates i got > > Segmentation Fault (core
> dumped) error

Post the source code for the shared object and a small c program that compiles
and demonstrates the problem.

Rick


Andrew Golubsky

unread,
Jul 3, 2001, 9:31:47 AM7/3/01
to
Please help me
Source code for SO Object :

library Test_Plugin;
Function Test_Function(A:Byte):Byte;stdcall;
Begin
Result:=A+1;
End;
exports Test_Function;
{$SONAME 'plugin'}
{$SOVERSION '1'}
begin
end.

Source code for test program

#include <stdio.h>
#include <dlfcn.h>
int main(int,char**) {
void* handle=dlopen("/work/PLUGIN/libTest_Plugin.so.1",RTLD_NOW);
if (!handle) {
printf("load error\n");
return -1;
};
printf("load success\n");
dlclose(handle);
printf("dlclose complete\n");
return 0;
};
Source code for makefile:
CXX=gcc

test: \
test.o
$(CXX) -DDEBUG -g -o $@ $^ -ldl

test.o: test.cpp
$(CXX) -c -g -o $@ $<


Thank you !


Rick Ross <ri...@rick-ross.com> сообщил в новостях
следующее:3B41B2F6...@rick-ross.com...

bugger

unread,
Jul 3, 2001, 1:25:08 PM7/3/01
to
: "Andrew Golubsky" <da...@transts.ru> wrote:

> $(CXX) -DDEBUG -g -o $@ $^ -ldl

Use

$(CXX) -DDEBUG -g -o $@ $^ -ldl -lpthread

Rick Ross

unread,
Jul 3, 2001, 6:24:06 PM7/3/01
to
> Please help me

I'll try...

>
> int main(int,char**) {

I received a compiler error here. I added argc, and argv as parameters.

> };

(You don't need to terminate closing brackets with a semicolon in C.. Too much
Kylix lately! ;)

> test: \

NEVER NEVER use test as a name of a file, since there usually is a test app in
the path (probably /usr/bin/test). I changed this to openso as well as the
appropriate file references.

>
> test.o
> $(CXX) -DDEBUG -g -o $@ $^ -ldl
>
> test.o: test.cpp
> $(CXX) -c -g -o $@ $<

I ran the generated openso (./openso) and it worked as expected. So first try
changing the name from test to something else and rerun the test. If that
still does not work, post what versions of the kernel, glibc, and the output
of
ldd /libTest_Plugin.so.1

HTH

Rick

Andrew Golubsky

unread,
Jul 4, 2001, 6:27:09 AM7/4/01
to
Thank you very much Rick Ross and Bugger!
I changed names of files and C++ project , added to makefile -lpthread
and now everything is ok
Once more : Thank you !

PS
with out -lpthread i got error


Rick Ross

unread,
Jul 4, 2001, 8:57:03 AM7/4/01
to
> Once more : Thank you !

Your welcome!

> PS
> with out -lpthread i got error

Interesting.. I didn't need to use the pthread libraries...

Rick


0 new messages