View topic - Using dlopen() in PhAb project

Using dlopen() in PhAb project

Read-only archive of qnx.cafe (generail discussion forum) at inn.qnx.com

Using dlopen() in PhAb project

Postby Garry » Mon Oct 04, 2004 12:44 pm

Hello,
I'm having a little difficulty using dlopen() from my PhAb project.
I've created my library like so:

gcc -shared -fPIC -c -I/home/gman/Projects/C -I.
/home/gman/Projects/Plugins/test_plugin.c -o /home/gman/test.so

it compiles no problems.

And have opened it using dlopen, like so:

so_handle = dlopen((const char *) "/home/gman/test.so",RTLD_NOW);

But dlopen returns a NULL pointer and dlerror() reports:

dlopen error: Shared library is corrupted

Do I have to make my entire PhAb program a dynamically linked program?
If so, how?

Thanks a lot

Garry
Garry
 

Re: Using dlopen() in PhAb project

Postby Colin Burgess » Mon Oct 04, 2004 12:44 pm

You are only compiling it (because of the -c option)

So it is still only a .o file, even though you are telling qcc to call
it a .so

Garry wrote:
Hello,
I'm having a little difficulty using dlopen() from my PhAb project.
I've created my library like so:

gcc -shared -fPIC -c -I/home/gman/Projects/C -I.
/home/gman/Projects/Plugins/test_plugin.c -o /home/gman/test.so

it compiles no problems.

And have opened it using dlopen, like so:

so_handle = dlopen((const char *) "/home/gman/test.so",RTLD_NOW);

But dlopen returns a NULL pointer and dlerror() reports:

dlopen error: Shared library is corrupted

Do I have to make my entire PhAb program a dynamically linked program?
If so, how?

Thanks a lot

Garry

--
cburgess@qnx.com
Colin Burgess
 

Re: Using dlopen() in PhAb project

Postby Colin Burgess » Mon Oct 04, 2004 4:01 pm

Put your gmalloc in a utility shared lib, and link your executable and
your shared lib against it.

Garry wrote:

Colin Burgess wrote:

You are only compiling it (because of the -c option)

So it is still only a .o file, even though you are telling qcc to call
it a .so


Doh! I took that away and it's OK now. Thanks.

Just one more thing, from within my shared object, I cannot access
functions which are available from outside the shared object, but in the
same process. i.e. I've got my own gmalloc() call, which I use to debug
my mallocs, I can use it anywhere in my program, except in the shared
object, although printf() does work.

Thanks again.

Garry

--
cburgess@qnx.com
Colin Burgess
 

Re: Using dlopen() in PhAb project

Postby Garry » Mon Oct 04, 2004 4:07 pm

Colin Burgess wrote:
You are only compiling it (because of the -c option)

So it is still only a .o file, even though you are telling qcc to call
it a .so


Doh! I took that away and it's OK now. Thanks.

Just one more thing, from within my shared object, I cannot access
functions which are available from outside the shared object, but in the
same process. i.e. I've got my own gmalloc() call, which I use to debug
my mallocs, I can use it anywhere in my program, except in the shared
object, although printf() does work.

Thanks again.

Garry
Garry
 

Re: Using dlopen() in PhAb project

Postby Garry » Mon Oct 04, 2004 5:07 pm

Colin Burgess wrote:
Put your gmalloc in a utility shared lib, and link your executable and
your shared lib against it.

Garry wrote:

Colin Burgess wrote:

You are only compiling it (because of the -c option)

So it is still only a .o file, even though you are telling qcc to
call it a .so


Doh! I took that away and it's OK now. Thanks.

Just one more thing, from within my shared object, I cannot access
functions which are available from outside the shared object, but in
the same process. i.e. I've got my own gmalloc() call, which I use to
debug my mallocs, I can use it anywhere in my program, except in the
shared object, although printf() does work.

Thanks again.

Garry



Thank you again Colin, it's working great now.

Garry
Garry
 


Return to qnx.cafe

Who is online

Users browsing this forum: No registered users and 1 guest

cron