public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: Trying to link an MSVC DLL with a Cygwin Application
@ 2004-05-04  5:23 Billinghurst, David (CALCRTS)
  2004-05-04  5:57 ` john george
  0 siblings, 1 reply; 7+ messages in thread
From: Billinghurst, David (CALCRTS) @ 2004-05-04  5:23 UTC (permalink / raw)
  To: john george, cygwin

> From: john george
>
> I'm trying to link a MSVC++  created DLL with a cygwin
> application. 
>
> ...
>
> This gives me undefined refernce to function name ...
> 
> Is there anything that I'm missing?

The g++ and MSVC++ mangle C++ names differently.  This makes
it very difficult (perhaps impossible) to link a MSVC++ 
created DLL with a g++ compiled (cygwin or mingw) application.

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

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

* RE: Trying to link an MSVC DLL with a Cygwin Application
  2004-05-04  5:23 Trying to link an MSVC DLL with a Cygwin Application Billinghurst, David (CALCRTS)
@ 2004-05-04  5:57 ` john george
  2004-05-04 13:47   ` Igor Pechtchanski
  2004-05-04 18:10   ` Jörg Schaible
  0 siblings, 2 replies; 7+ messages in thread
From: john george @ 2004-05-04  5:57 UTC (permalink / raw)
  To: Billinghurst, David (CALCRTS), cygwin

Can i resolve the name mangling issue by adding the 
extern "C" declaration for every function that I'm
exporting in the MSVC created DLL.
I tried this but doesn't seem to work.Is there any
other way to do this.
Thanks
john


--- "Billinghurst, David (CALCRTS)"
<david.billinghurst@comalco.riotinto.com.au> wrote:
> > From: john george
> >
> > I'm trying to link a MSVC++  created DLL with a
> cygwin
> > application. 
> >
> > ...
> >
> > This gives me undefined refernce to function name
> ...
> > 
> > Is there anything that I'm missing?
> 
> The g++ and MSVC++ mangle C++ names differently. 
> This makes
> it very difficult (perhaps impossible) to link a
> MSVC++ 
> created DLL with a g++ compiled (cygwin or mingw)
> application.
> 
> --
> 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/
> 



	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

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

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

* RE: Trying to link an MSVC DLL with a Cygwin Application
  2004-05-04  5:57 ` john george
@ 2004-05-04 13:47   ` Igor Pechtchanski
  2004-05-04 18:10   ` Jörg Schaible
  1 sibling, 0 replies; 7+ messages in thread
From: Igor Pechtchanski @ 2004-05-04 13:47 UTC (permalink / raw)
  To: john george; +Cc: cygwin

On Mon, 3 May 2004, john george wrote:

> --- "Billinghurst, David (CALCRTS)" <david<dot>billinghurst<at>comalco<dot>riotinto<dot>com<dot>au> wrote:

<http://cygwin.com/acronyms/#PCYMTNQREAIYR>.

> > > From: john george
> > >
> > > I'm trying to link a MSVC++ created DLL with a cygwin application.
> > >
> > > ...
> > >
> > > This gives me undefined refernce to function name
> > ...
> > >
> > > Is there anything that I'm missing?
> >
> > The g++ and MSVC++ mangle C++ names differently.  This makes it very
> > difficult (perhaps impossible) to link a MSVC++ created DLL with a g++
> > compiled (cygwin or mingw) application.
>
> Can i resolve the name mangling issue by adding the extern "C"
> declaration for every function that I'm exporting in the MSVC created
> DLL.  I tried this but doesn't seem to work.  Is there any other way to
> do this.

Theoretically, the above should have worked, as long as you turned off
name mangling on *both* ends (i.e., declared the exported functions as
'extern "C"' in both the MSVC DLL, and your program headers).

Checking whether the undefined reference is to the mangled name or not
should tell you on which end you forgot to 'extern "C"' the function.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

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

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

* RE: Trying to link an MSVC DLL with a Cygwin Application
  2004-05-04  5:57 ` john george
  2004-05-04 13:47   ` Igor Pechtchanski
@ 2004-05-04 18:10   ` Jörg Schaible
       [not found]     ` <4098984F.8010505@luukku.com>
  1 sibling, 1 reply; 7+ messages in thread
From: Jörg Schaible @ 2004-05-04 18:10 UTC (permalink / raw)
  To: cygwin

john george wrote:

> Can i resolve the name mangling issue by adding the
> extern "C" declaration for every function that I'm
> exporting in the MSVC created DLL.
> I tried this but doesn't seem to work.Is there any
> other way to do this.

Be aware, that there is more than just a compatible call. You have to
recognize, that you have two different RT-libs and therefore also two
memory managers. Said that, you cannot allocate memory from the first one
and set it free on the second. While this is quite obvious with malloc and
friends, you have also to take care of strdup or fopen or ...

Regards,
Jörg


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

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

* Re: Trying to link an MSVC DLL with a Cygwin Application
       [not found]     ` <4098984F.8010505@luukku.com>
@ 2004-05-05 16:58       ` Jörg Schaible
  0 siblings, 0 replies; 7+ messages in thread
From: Jörg Schaible @ 2004-05-05 16:58 UTC (permalink / raw)
  To: cygwin

Please keep replies on the list!

On Wednesday 05 May 2004 09:31, you wrote:
Jt> Jörg Schaible wrote:
Jt>
Jt> > john george wrote:
Jt> >
Jt> >
Jt> >>Can i resolve the name mangling issue by adding the
Jt> >>extern "C" declaration for every function that I'm
Jt> >>exporting in the MSVC created DLL.
Jt> >>I tried this but doesn't seem to work.Is there any
Jt> >>other way to do this.
Jt> >
Jt> >
Jt> > Be aware, that there is more than just a compatible call. You have to
Jt> > recognize, that you have two different RT-libs and therefore also two
Jt> > memory managers. Said that, you cannot allocate memory from the first
 one Jt> > and set it free on the second. While this is quite obvious with
 malloc and Jt> > friends, you have also to take care of strdup or fopen or
 ...
Jt>
Jt> Aren't cygwin given pointers and msvcrt given pointers interchangeable..?
Jt>
Jt> Well I'm not going to try it but it could be handy to know...

This has nothing to do with Cygwin itself, but is true for any combination of 
different RT-Libs (Cygwin, MS, Borland, ...)

Regards,
Jörg

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

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

* RE: Trying to link an MSVC DLL with a Cygwin Application
@ 2004-05-04  9:07 Arash Partow
  0 siblings, 0 replies; 7+ messages in thread
From: Arash Partow @ 2004-05-04  9:07 UTC (permalink / raw)
  To: cygwin

Hi David,

That is a false assumption, I have been able to link a REAL win32 dll
against a cygwin application however linking a cygwin compiled dll
into a MSVC app is where you will come into troubles. This is because
neither cygwin's or ming's dlltool create dlls as specified by MS's
dll specification.

The name mangling is an issue from VC++ POV not the other way round.


My experience comes from building a win32 dll in Borland C++ builder
then having a simple console based cygwin gcc compiled app exercise
the dll's API - which btw was successful.




Arash Partow

__________________________________________________
Be one who knows what they don't know,
Instead of being one who knows not what they don't know,
Thinking they know everything about all things.
http://www.partow.net




>>From: john george
>>
>>I'm trying to link a MSVC++  created DLL with a cygwin
>>application.
>>
>>...
>>
>>This gives me undefined refernce to function name ...
>>
>>Is there anything that I'm missing?
>
>The g++ and MSVC++ mangle C++ names differently.  This makes
>it very difficult (perhaps impossible) to link a MSVC++ created DLL with a 
>g++ compiled (cygwin or mingw) application.
>
>--
>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/







.

_________________________________________________________________
Personalise your mobile chart ringtones and polyphonics. Go to  
http://ringtones.com.au/ninemsn/control?page=/ninemsn/main.jsp


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

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

* Trying to link an MSVC DLL with a Cygwin Application
@ 2004-05-04  5:07 john george
  0 siblings, 0 replies; 7+ messages in thread
From: john george @ 2004-05-04  5:07 UTC (permalink / raw)
  To: cygwin

Hi ,
I'm trying to link a MSVC++  created DLL with a cygwin
application. Could you please provide me any useful
link realted to this issue.
I'm trying the following commands but it doesn't seem
to work:

Trying to convert the MSVC++ created DLL to a shared
lib using the dlltool

dlltool --def test.def --dllname msvctest.dll
-llibtest.a
(test.def has the exported symbol names)

I keep this libtest.a in the /lib directory so that
there won't be any LD_LIBRARY_PATH related issues.
After this step I try 

gcc mytest.c -ltest

This gives me undefined refernce to function name ...

Is there anything that I'm missing?

Regards,
john




	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

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

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

end of thread, other threads:[~2004-05-05 16:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-04  5:23 Trying to link an MSVC DLL with a Cygwin Application Billinghurst, David (CALCRTS)
2004-05-04  5:57 ` john george
2004-05-04 13:47   ` Igor Pechtchanski
2004-05-04 18:10   ` Jörg Schaible
     [not found]     ` <4098984F.8010505@luukku.com>
2004-05-05 16:58       ` Jörg Schaible
  -- strict thread matches above, loose matches on Subject: below --
2004-05-04  9:07 Arash Partow
2004-05-04  5:07 john george

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).