delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/07/06/05:42:16

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
X-Envelope-Sender-Is: Andrej DOT Borsenkow AT mow DOT siemens DOT ru (at relayer david.siemens.de)
From: "Andrej Borsenkow" <Andrej DOT Borsenkow AT mow DOT siemens DOT ru>
To: <cygwin AT sourceware DOT cygnus DOT com>
Subject: Accessing exported variables in DLL with dlsym().
Date: Thu, 6 Jul 2000 12:58:55 +0400
Message-ID: <000201bfe728$6a208f10$21c9ca95@mow.siemens.ru>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700
Importance: Normal

I am trying to port a program that opens dynamic library with dlopen()
and looks up symbol with dlsym(). This works for function reference but
not for variable. The porgram is:

main.c:

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

main() {
    int (*foo)(void);
    void *libfoo;

    libfoo = dlopen ("libfoo.dll", 0);
    foo = dlsym (libfoo, "foo");
    foo();
}

foo.c:

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

__declspec (dllexport) extern foo (void);

foo() {
    char *bar;
    void *libbar;

    libbar = dlopen ("libbar.dll", 0);
    bar = dlsym (libbar, "bar");
    puts (bar);
}


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019