in reply to Problem with C::DynaLib

I suppose the lib to be loaded needs to be a shared (aka dynamic) object — from your .o extension I figure it is not.

Compile your C test code as follows (and then load the .so file):

$ cc -c -fPIC test.c $ cc -shared test.o -o test.so

Update: just tried it, and although it works fine (when compiling as shown above) with code samples such as

int test() // ->DeclareSub("test", "i") { return 42; } void test() // ->DeclareSub("test", "") { printf("WORKS!\n"); }

I couldn't get it to work with your sample returning a char* (I get an "Illegal instruction" exception (SIGILL)).  Apparently, "p" is not the appropriate type specifier here...

Replies are listed 'Best First'.
Re^2: Problem with C::DynaLib
by Anonymous Monk on Jan 18, 2010 at 07:31 UTC
    Thanks a lot.
    I wasn't aware of the cc - shared thing.
    Thanks =)