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.
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
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
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...
> $(CXX) -DDEBUG -g -o $@ $^ -ldl
Use
$(CXX) -DDEBUG -g -o $@ $^ -ldl -lpthread
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
PS
with out -lpthread i got error
Your welcome!
> PS
> with out -lpthread i got error
Interesting.. I didn't need to use the pthread libraries...
Rick