public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* cygwin C++ DLLs and inter-operation with M$OFT
@ 2002-02-13  2:57 Dylan Cuthbert
  2002-02-13  7:37 ` Larry Hall (RFK Partners, Inc)
  0 siblings, 1 reply; 7+ messages in thread
From: Dylan Cuthbert @ 2002-02-13  2:57 UTC (permalink / raw)
  To: Cygwin@Cygwin. Com

To anyone who can help,

We've been having some fun creating DLLs that need to be loaded by some
Visual C++ code.  The code in the dll itself, ie. the interface is C so
there aren't any name mangling problems.  However, using v3.0.3 of GCC we
get unresolved symbol errors for any libstdc++ we do within the dll.  These
errors don't occur after using the -V 2.95.3-5 option to gcc to revert to
the originally packaged compiler - I had a good poke around but I couldn't
work out why the symbols couldn't be resolved.

Anyway, after reverting to 2.95.3-5, our test code compiles but when we call
any cygwin dll code (from the VS application) we get an exception error in
cygwin1.dll - if the code uses any stdlib type stuff (such as memory
allocation, printf etc).  There is no C++ code in there at all now.

I've read through the faqs and documentation and searched the mailing list
but I can't find any fixes for this problem (although a couple of other
people do mention it).  Is there just some obvious initialisation stuff I'm
missing somewhere?

Regards

---------------------------------
Q-Games, Dylan Cuthbert.
http://www.q-games.com


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cygwin C++ DLLs and inter-operation with M$OFT
  2002-02-13  2:57 cygwin C++ DLLs and inter-operation with M$OFT Dylan Cuthbert
@ 2002-02-13  7:37 ` Larry Hall (RFK Partners, Inc)
  2002-02-13 19:06   ` cygwin gcc DLLs loaded by Visual C++ crashing Dylan Cuthbert
  0 siblings, 1 reply; 7+ messages in thread
From: Larry Hall (RFK Partners, Inc) @ 2002-02-13  7:37 UTC (permalink / raw)
  To: Dylan Cuthbert, Cygwin@Cygwin. Com

At 05:58 AM 2/13/2002, Dylan Cuthbert wrote:
>To anyone who can help,
>
>We've been having some fun creating DLLs that need to be loaded by some
>Visual C++ code.  The code in the dll itself, ie. the interface is C so
>there aren't any name mangling problems.  However, using v3.0.3 of GCC we
>get unresolved symbol errors for any libstdc++ we do within the dll.  These
>errors don't occur after using the -V 2.95.3-5 option to gcc to revert to
>the originally packaged compiler - I had a good poke around but I couldn't
>work out why the symbols couldn't be resolved.
>
>Anyway, after reverting to 2.95.3-5, our test code compiles but when we call
>any cygwin dll code (from the VS application) we get an exception error in
>cygwin1.dll - if the code uses any stdlib type stuff (such as memory
>allocation, printf etc).  There is no C++ code in there at all now.
>
>I've read through the faqs and documentation and searched the mailing list
>but I can't find any fixes for this problem (although a couple of other
>people do mention it).  Is there just some obvious initialisation stuff I'm
>missing somewhere?


Probably.  This has been mentioned in the past.  You want to look at the 
Cygwin initialization code to see what happens there.  It needs to happen
when the DLL is loaded by non-Cygwin apps as well.  Some of this may come
for free at this point.  Discussion of this issue was quite some time ago
(check the developer email archives if you're curious) and I don't remember
the final consensus and/or changes.  But, the archives should have the 
history and the startup code should give you a hint of the current state.



Larry Hall                              lhall@rfk.com
RFK Partners, Inc.                      http://www.rfk.com
838 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cygwin gcc DLLs loaded by Visual C++ crashing
  2002-02-13  7:37 ` Larry Hall (RFK Partners, Inc)
@ 2002-02-13 19:06   ` Dylan Cuthbert
  2002-02-13 22:09     ` cygwin gcc DLLs loaded by Visual C++ crashing - SOLVED Dylan Cuthbert
  0 siblings, 1 reply; 7+ messages in thread
From: Dylan Cuthbert @ 2002-02-13 19:06 UTC (permalink / raw)
  To: Larry Hall (RFK Partners, Inc), Cygwin@Cygwin. Com

Thanks for the reply.

I have searched the mailing lists high and low and as far back as 1998 and
there are some references to this problem and some solutions, yet there are
no definitive "this works" type responses ( in fact, almost all the
responses I found seemed like temporary hacks ) and it would take a long
time to try implementing all the various solutions listed with no guarantee
they work.  Maybe I'm searching with the wrong string - I'm looking under
subjects such as "initializing cygwin from dll" or "initialize cygwin dll",
am I missing some important keyword?

The closest thing I have found is probably the "use LoadLibrary" to load the
cygwin.dll manually and then calling cygwin_dll_init(), but even that
crashes according to
http://sources.redhat.com/ml/cygwin/2001-08/msg00790.html  (couldn't find
any response confirming or denying this mail)

Then there's the (from 1998) use the "crt0.o" to link with and create a
dummy thread and a main() which doesn't exit - this seems like a complete
hack.  I think this is probably the wrong direction, right?

Then there's this comment from cgf -
http://sources.redhat.com/ml/cygwin/2000-12/msg00366.html which seems to say
that cygwin_dll_init() is the way to go.

However, when I try using cygwin_dll_init I get an exception error, I
couldn't find any definition of a function called cygwin_dll_init in any
header file or library file anywhere so I force-ably extern'ed it. Does it
really exist, if so, where?

Any ideas, anyone?

---------------------------------
Q-Games, Dylan Cuthbert.
http://www.q-games.com
----- Original Message -----
From: "Larry Hall (RFK Partners, Inc)" <lhall@rfk.com>
To: "Dylan Cuthbert" <dylan@q-games.com>; "Cygwin@Cygwin. Com"
<cygwin@cygwin.com>
Sent: Thursday, February 14, 2002 12:34 AM
Subject: Re: cygwin C++ DLLs and inter-operation with M$OFT


> At 05:58 AM 2/13/2002, Dylan Cuthbert wrote:
> >To anyone who can help,
> >
> >We've been having some fun creating DLLs that need to be loaded by some
> >Visual C++ code.  The code in the dll itself, ie. the interface is C so
> >there aren't any name mangling problems.  However, using v3.0.3 of GCC we
> >get unresolved symbol errors for any libstdc++ we do within the dll.
These
> >errors don't occur after using the -V 2.95.3-5 option to gcc to revert to
> >the originally packaged compiler - I had a good poke around but I
couldn't
> >work out why the symbols couldn't be resolved.
> >
> >Anyway, after reverting to 2.95.3-5, our test code compiles but when we
call
> >any cygwin dll code (from the VS application) we get an exception error
in
> >cygwin1.dll - if the code uses any stdlib type stuff (such as memory
> >allocation, printf etc).  There is no C++ code in there at all now.
> >
> >I've read through the faqs and documentation and searched the mailing
list
> >but I can't find any fixes for this problem (although a couple of other
> >people do mention it).  Is there just some obvious initialisation stuff
I'm
> >missing somewhere?
>
>
> Probably.  This has been mentioned in the past.  You want to look at the
> Cygwin initialization code to see what happens there.  It needs to happen
> when the DLL is loaded by non-Cygwin apps as well.  Some of this may come
> for free at this point.  Discussion of this issue was quite some time ago
> (check the developer email archives if you're curious) and I don't
remember
> the final consensus and/or changes.  But, the archives should have the
> history and the startup code should give you a hint of the current state.
>
>
>
> Larry Hall                              lhall@rfk.com
> RFK Partners, Inc.                      http://www.rfk.com
> 838 Washington Street                   (508) 893-9779 - RFK Office
> Holliston, MA 01746                     (508) 893-9889 - FAX
>


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cygwin gcc DLLs loaded by Visual C++ crashing - SOLVED
  2002-02-13 19:06   ` cygwin gcc DLLs loaded by Visual C++ crashing Dylan Cuthbert
@ 2002-02-13 22:09     ` Dylan Cuthbert
  2002-02-14  7:23       ` Christopher Faylor
  0 siblings, 1 reply; 7+ messages in thread
From: Dylan Cuthbert @ 2002-02-13 22:09 UTC (permalink / raw)
  To: Dylan Cuthbert, Larry Hall (RFK Partners, Inc), Cygwin@Cygwin. Com

[-- Attachment #1: Type: text/plain, Size: 5056 bytes --]


The FAQ/User Manual leads everyone in completely the wrong direction.

If anyone else wants to get CYGWIN C++ programs running as dlls loaded by
Visual C++ programs, use the attached example as a basis, it is *really*
simple.  This only allows Visual C++ to access the C functions of course,
but that allows the generation of a simplified layer to gcc's c++ and our
own c++ libraries.

We are now able to interface our cygwin programs with our Maya plugin (which
is forced unfortunately to use VC++).

Regards
---------------------------------
Q-Games, Dylan Cuthbert.
http://www.q-games.com

----- Original Message -----
From: "Dylan Cuthbert" <dylan@q-games.com>
To: "Larry Hall (RFK Partners, Inc)" <lhall@rfk.com>; "Cygwin@Cygwin. Com"
<cygwin@cygwin.com>
Sent: Thursday, February 14, 2002 12:06 PM
Subject: Re: cygwin gcc DLLs loaded by Visual C++ crashing


> Thanks for the reply.
>
> I have searched the mailing lists high and low and as far back as 1998 and
> there are some references to this problem and some solutions, yet there
are
> no definitive "this works" type responses ( in fact, almost all the
> responses I found seemed like temporary hacks ) and it would take a long
> time to try implementing all the various solutions listed with no
guarantee
> they work.  Maybe I'm searching with the wrong string - I'm looking under
> subjects such as "initializing cygwin from dll" or "initialize cygwin
dll",
> am I missing some important keyword?
>
> The closest thing I have found is probably the "use LoadLibrary" to load
the
> cygwin.dll manually and then calling cygwin_dll_init(), but even that
> crashes according to
> http://sources.redhat.com/ml/cygwin/2001-08/msg00790.html  (couldn't find
> any response confirming or denying this mail)
>
> Then there's the (from 1998) use the "crt0.o" to link with and create a
> dummy thread and a main() which doesn't exit - this seems like a complete
> hack.  I think this is probably the wrong direction, right?
>
> Then there's this comment from cgf -
> http://sources.redhat.com/ml/cygwin/2000-12/msg00366.html which seems to
say
> that cygwin_dll_init() is the way to go.
>
> However, when I try using cygwin_dll_init I get an exception error, I
> couldn't find any definition of a function called cygwin_dll_init in any
> header file or library file anywhere so I force-ably extern'ed it. Does it
> really exist, if so, where?
>
> Any ideas, anyone?
>
> ---------------------------------
> Q-Games, Dylan Cuthbert.
> http://www.q-games.com
> ----- Original Message -----
> From: "Larry Hall (RFK Partners, Inc)" <lhall@rfk.com>
> To: "Dylan Cuthbert" <dylan@q-games.com>; "Cygwin@Cygwin. Com"
> <cygwin@cygwin.com>
> Sent: Thursday, February 14, 2002 12:34 AM
> Subject: Re: cygwin C++ DLLs and inter-operation with M$OFT
>
>
> > At 05:58 AM 2/13/2002, Dylan Cuthbert wrote:
> > >To anyone who can help,
> > >
> > >We've been having some fun creating DLLs that need to be loaded by some
> > >Visual C++ code.  The code in the dll itself, ie. the interface is C so
> > >there aren't any name mangling problems.  However, using v3.0.3 of GCC
we
> > >get unresolved symbol errors for any libstdc++ we do within the dll.
> These
> > >errors don't occur after using the -V 2.95.3-5 option to gcc to revert
to
> > >the originally packaged compiler - I had a good poke around but I
> couldn't
> > >work out why the symbols couldn't be resolved.
> > >
> > >Anyway, after reverting to 2.95.3-5, our test code compiles but when we
> call
> > >any cygwin dll code (from the VS application) we get an exception error
> in
> > >cygwin1.dll - if the code uses any stdlib type stuff (such as memory
> > >allocation, printf etc).  There is no C++ code in there at all now.
> > >
> > >I've read through the faqs and documentation and searched the mailing
> list
> > >but I can't find any fixes for this problem (although a couple of other
> > >people do mention it).  Is there just some obvious initialisation stuff
> I'm
> > >missing somewhere?
> >
> >
> > Probably.  This has been mentioned in the past.  You want to look at the
> > Cygwin initialization code to see what happens there.  It needs to
happen
> > when the DLL is loaded by non-Cygwin apps as well.  Some of this may
come
> > for free at this point.  Discussion of this issue was quite some time
ago
> > (check the developer email archives if you're curious) and I don't
> remember
> > the final consensus and/or changes.  But, the archives should have the
> > history and the startup code should give you a hint of the current
state.
> >
> >
> >
> > Larry Hall                              lhall@rfk.com
> > RFK Partners, Inc.                      http://www.rfk.com
> > 838 Washington Street                   (508) 893-9779 - RFK Office
> > Holliston, MA 01746                     (508) 893-9889 - FAX
> >
>
>
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
>

[-- Attachment #2: testdll.zip --]
[-- Type: application/x-zip-compressed, Size: 10369 bytes --]

[-- Attachment #3: Type: text/plain, Size: 214 bytes --]

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cygwin gcc DLLs loaded by Visual C++ crashing - SOLVED
  2002-02-13 22:09     ` cygwin gcc DLLs loaded by Visual C++ crashing - SOLVED Dylan Cuthbert
@ 2002-02-14  7:23       ` Christopher Faylor
  2002-02-14 16:14         ` Dylan Cuthbert
  0 siblings, 1 reply; 7+ messages in thread
From: Christopher Faylor @ 2002-02-14  7:23 UTC (permalink / raw)
  To: cygwin

On Thu, Feb 14, 2002 at 03:09:47PM +0900, Dylan Cuthbert wrote:
>
>The FAQ/User Manual leads everyone in completely the wrong direction.
>
>If anyone else wants to get CYGWIN C++ programs running as dlls loaded by
>Visual C++ programs, use the attached example as a basis, it is *really*
>simple.  This only allows Visual C++ to access the C functions of course,
>but that allows the generation of a simplified layer to gcc's c++ and our
>own c++ libraries.
>
>We are now able to interface our cygwin programs with our Maya plugin (which
>is forced unfortunately to use VC++).

Hmm.  I didn't see an update for the FAQ which "reverses the direction"
in your attachment.  Did I miss something?

You do realize that if you are using the cygwin DLL, your code is GPLed,
right?

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cygwin gcc DLLs loaded by Visual C++ crashing - SOLVED
  2002-02-14  7:23       ` Christopher Faylor
@ 2002-02-14 16:14         ` Dylan Cuthbert
  2002-02-14 16:35           ` Christopher Faylor
  0 siblings, 1 reply; 7+ messages in thread
From: Dylan Cuthbert @ 2002-02-14 16:14 UTC (permalink / raw)
  To: cygwin


It surely doesn't matter if we aren't distributing our code to anyone other
than ourselves, otherwise you've probably got  millions of offenders of the
GPL.  We're only using cygwin to prototype some stuff, not to make any
viable product as it just isn't stable/reliable/secure enough unfortunately
(yet).  Its a brilliant environment for creativity and experimentation
though.

Give me a break, I will update the FAQ with a patch just as I did for the
DirectX/DirectDraw 8 stuff, if only for the knowledge that other people
don't have to go trawling through thousands of pages of out-dated advice
only to find none of it works (documentation karma). I'll also put that zip
file up on the page below. (it works for both gcc 2.95.3-5 and 3.0.3 by the
way)

We're still getting some problems (an exception) unloading the dll we
created, but only from within the Maya plugin. Apart from that it all seems
to work fine so far.  I think that problem has more to do with the way Maya
calls its plugins (as static modules in memory) and is unrelated to cygwin I
hope.

Best Regards

---------------------------------
Q-Games, Dylan Cuthbert.
http://www.q-games.com/personal/utils

----- Original Message -----
From: "Christopher Faylor" <cgf@redhat.com>
To: <cygwin@cygwin.com>
Sent: Friday, February 15, 2002 12:23 AM
Subject: Re: cygwin gcc DLLs loaded by Visual C++ crashing - SOLVED


> On Thu, Feb 14, 2002 at 03:09:47PM +0900, Dylan Cuthbert wrote:
> >
> >The FAQ/User Manual leads everyone in completely the wrong direction.
> >
> >If anyone else wants to get CYGWIN C++ programs running as dlls loaded by
> >Visual C++ programs, use the attached example as a basis, it is *really*
> >simple.  This only allows Visual C++ to access the C functions of course,
> >but that allows the generation of a simplified layer to gcc's c++ and our
> >own c++ libraries.
> >
> >We are now able to interface our cygwin programs with our Maya plugin
(which
> >is forced unfortunately to use VC++).
>
> Hmm.  I didn't see an update for the FAQ which "reverses the direction"
> in your attachment.  Did I miss something?
>
> You do realize that if you are using the cygwin DLL, your code is GPLed,
> right?
>
> cgf
>
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
>


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cygwin gcc DLLs loaded by Visual C++ crashing - SOLVED
  2002-02-14 16:14         ` Dylan Cuthbert
@ 2002-02-14 16:35           ` Christopher Faylor
  0 siblings, 0 replies; 7+ messages in thread
From: Christopher Faylor @ 2002-02-14 16:35 UTC (permalink / raw)
  To: cygwin

On Fri, Feb 15, 2002 at 09:14:56AM +0900, Dylan Cuthbert wrote:
>It surely doesn't matter if we aren't distributing our code to anyone
>other than ourselves, otherwise you've probably got millions of
>offenders of the GPL.

Right.  If you're only using it internally, you don't have to worry
about the GPL.

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-02-15  0:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-13  2:57 cygwin C++ DLLs and inter-operation with M$OFT Dylan Cuthbert
2002-02-13  7:37 ` Larry Hall (RFK Partners, Inc)
2002-02-13 19:06   ` cygwin gcc DLLs loaded by Visual C++ crashing Dylan Cuthbert
2002-02-13 22:09     ` cygwin gcc DLLs loaded by Visual C++ crashing - SOLVED Dylan Cuthbert
2002-02-14  7:23       ` Christopher Faylor
2002-02-14 16:14         ` Dylan Cuthbert
2002-02-14 16:35           ` Christopher Faylor

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 read-only IMAP folder(s) and NNTP newsgroup(s).