delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/12/31/01:19:00

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3FF26A27.7090301@keypro.fi>
Date: Wed, 31 Dec 2003 08:18:15 +0200
From: Jani Tiainen <jani DOT tiainen AT keypro DOT fi>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4
MIME-Version: 1.0
To: Cygwin List <cygwin AT cygwin DOT com>
Subject: Re: DLL and external symbols
References: <3FF1EFB3 DOT 5000509 AT keypro DOT fi> <6 DOT 0 DOT 1 DOT 1 DOT 0 DOT 20031230230034 DOT 03baab08 AT 127 DOT 0 DOT 0 DOT 1>
In-Reply-To: <6.0.1.1.0.20031230230034.03baab08@127.0.0.1>

Larry Hall wrote:
> At 04:35 PM 12/30/2003, Jani Tiainen you wrote:
> 
>>Hi,
>>
>>I'm sure that this has been answered several times, but I'll ask again because couldn't find any solution by myself.
>>
>>I would like to build DLL (or any other sort of library) that refers to external symbols in main application.
>>
>>So far I have been able to build non-working constructs. =)
>>

[snipsnip]

>>
>>Now how I can get this working, or is it possible at all?
> 
> 
> 
> It's possible but you have to move "funcInMain()" into the DLL with 
> "funcInMyLib()" or into another DLL.  That's the straight-forward 
> answer.

Yes, that one I knew already. Problem isn't actually function, in my 
real case it's more like having some globals that libraries should be 
able to read.

So let's extend this main.c a little bit:

#include <stdio.h>

/* Global that is set here and printed from DLL */
int anotherValue = 0;

/* Function in DLL */
extern void funcInMyLib(int);

void funcInMain(int i)
{
     printf("funcInMain(%ld) (anotherValue=%d)\n", i, anotherValue);
}

int main(int argc, char **argv)
{
     antoherValue = 123;
     funcInMyLib(1);
     return 0;
}

--------

Now, that's what I really want to do, or at least something equivalent, 
more portable solution. (I'm really trying to port bigger application 
that has plugin modules built like this.)

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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