[Ecls-list] problem with shared libraries
franco smith
1919 at keromail.com
Sun Jul 7 09:02:12 UTC 2002
yo
while trying to understand what was wrong with perl and ecls, i find out that perl wasn't the mainly problem, but shared libraries were.
here's my test programs with their respective outputs:
// sadone.c ----------------------------------------
#include <ecls/h/ecls.h>
#include <string.h>
void _inita() {
int argc = 1;
char * argv[2] = { "/home/bah/perl/ecls/a.out", NULL };
printf("hello, i start booting\n");
cl_boot(argc,argv);
printf("end boot\n");
}
int main() {
_inita();
return 0;
}
// end ------------------------------------------
gcc -L/usr/local/lib -L/usr/local/lib/ecls/ -I /usr/local/lib sadone.c -lecls -lclos -llsp -lgmp -lgc -ldl -lgmp -lm
~/perl/ecls$ ./a.out
hello, i start booting
end boot
works fine :)
now here's my shared library:
//sad.c --------------------------------------------
#include <ecls/h/ecls.h>
#include <string.h>
void _inita() {
int argc = 1;
char * argv[2] = { "/home/bah/perl/ecls/a.out", NULL };
printf("hello, i start booting\n");
cl_boot(argc,argv);
printf("end boot\n");
}
// end ---------------------------------------------
gcc -I/usr/local/lib -c sad.c
gcc -nostdlib -rdynamic -shared -L/usr/local/lib sad.o -o sad.so -L/usr/local/lib/ecls/ -lecls -lclos -llsp -lgmp -lgc -ldl -lgmp -lm
cp sad.so libsad.so
first test program for the shared library:
//sadmain.c -----------------------------------------
#include <dlfcn.h>
int main() {
void *h = dlopen ("/home/bah/perl/ecls/sad.so", RTLD_NOW | RTLD_GLOBAL);
void (*boota)() = dlsym(h, "_inita");
if(!boota) printf("dlsym: %s\n",dlerror());
boota();
dlclose(h); return 0;
}
//end -----------------------------------------------
gcc -rdynamic sadmain.c -ldl
~/perl/ecls$ ./a.out
hello, i start booting
Segmentation fault (core dumped)
second test program for the shared library:
// sadmain2.c ---------------------------------------
int main() {
_inita();
return 0;
}
//end ----------------------------------------------
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
gcc -L. sadmain2.c -lsad
~/perl/ecls$ ./a.out
hello, i start booting
Segmentation fault (core dumped)
ok
this is really annoying as i need to call cl_boot from a .so
i tried to understand where does that core dump come from, but i have some difficulties with handling the cl_boot code :(
especially, i really don't get how the fact i call cl_boot from a .so could change anything
but i'd really like to get this function to work into a shared library, and if you know the reason of that behaviour, or if you know how i could find the reason :) please tell me
thanks
--
Powered by Outblaze
More information about the ecl-devel
mailing list