linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Henry Margies <henry.margies@gmx.de>
To: linux-c-programming@vger.kernel.org
Subject: setenv and dlopen
Date: Tue, 25 Oct 2005 19:52:04 +0200	[thread overview]
Message-ID: <1130262724.7414.14.camel@localhost.localdomain> (raw)

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!


             reply	other threads:[~2005-10-25 17:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-25 17:52 Henry Margies [this message]
2005-10-25 18:20 ` setenv and dlopen Christoph Bussenius
2005-10-26  8:21   ` Henry Margies
2005-10-26 14:46 ` Glynn Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1130262724.7414.14.camel@localhost.localdomain \
    --to=henry.margies@gmx.de \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).