linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* setenv and dlopen
@ 2005-10-25 17:52 Henry Margies
  2005-10-25 18:20 ` Christoph Bussenius
  2005-10-26 14:46 ` Glynn Clements
  0 siblings, 2 replies; 4+ messages in thread
From: Henry Margies @ 2005-10-25 17:52 UTC (permalink / raw)
  To: linux-c-programming

Hi all,

I have a problem using dlopen and setting the LD_LIBRARY_PATH with
putenv or setenv. 


Here is my test code:

#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <unistd.h>

int main(int argn, char** argv)
{
        void* handle;
        int   ret;

        putenv("LD_LIBRARY_PATH=.");
        putenv("PATH=.");

        handle = dlopen("libmylib.so", RTLD_LAZY);

        if (NULL == handle) {
                printf("error: %s\n", dlerror());
        }

        if (2 == argn)
                return 0;

        ret = execlp("dltest", "dltest", "break", NULL);

        if (ret)
                perror("Error in starting dltest: ");
	return ret;
}


I also tried setenv and absolute path-names for LD_LIBRARY_PATH. Setting
LD_LIBRARY_PATH on the console works perfectly. And as you can see,
setting the PATH variable using putenv is also working for execlp.


Any suggestions?


Henry


-- 
Hi! I'm a .signature virus! Copy me into your
~/.signature to help me spread!


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-10-26 14:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-25 17:52 setenv and dlopen Henry Margies
2005-10-25 18:20 ` Christoph Bussenius
2005-10-26  8:21   ` Henry Margies
2005-10-26 14:46 ` Glynn Clements

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).