This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: DLL and external symbols


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]