This is the mail archive of the cygwin 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: Circular dependency problem


John Emmas wrote:

> functions contained in the other one).  If I was programming in Microsoft
> VC++ I'd normally resolve this by exporting the relevant functions.
> Exporting them (I believe) tells the linker that any unresolved function
> addresses will be resolved at run time (hence, dynamic linking).

That's not how DLLs work.  All references must be defined at link time,
there is no way to defer them to runtime unless you explicitly use
LoadLibrary/GetProcAddress and function pointers.  __declspec(dllexport)
does not change the situation at all.  What you probably meant was that
you (or perhaps the IDE did it for you) created a .def file which lists
the exported functions of a DLL before it actually exists, which can be
used to create an import library for linking.

> I don't know how the equivalent technology works in gcc but whatever it
> involves, the project compiles and links fine on my Linux box.  However,
> I can't make it build with Cygwin.  Both branches compile successfully but
> neither will link because the other one hasn't been built yet.
> 
> Is there anywhere where I can find some information about how to make
> this work?  I could probably make a cut-down version if anyone wants to see
> the problem for themselves.

Create a .def file listing the exported functions of library A, and then
generate an import library from that.  Link library B against the
library A import lib and at the same time create an import library for
B.  Then link library A against that.

$ dlltool -d libA.def -l libA.dll.a
$ gcc -shared $libB_objects -o libB.dll -L. -lA \
  -Wl,--out-implib,libB.dll.a
$ gcc -shared $libA_objects -o libA.dll -L. -lB

Brian

--
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]