public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: Using DLL compiled with Cygwin inside Visual Studio 2010
@ 2014-09-14  9:56 איציק בק
  2014-09-14 10:37 ` Csaba Raduly
  2014-09-14 23:24 ` Mark Geisert
  0 siblings, 2 replies; 7+ messages in thread
From: איציק בק @ 2014-09-14  9:56 UTC (permalink / raw)
  To: cygwin

>>I've read already tremendous amount of articles, tutorials, and
>>instructions about how to solve my problem - but still - no gain. I
>>just can't put it into work.

>>My goal is pretty simple: I want to compile a DLL file using Cygwin
>>gcc tool, and then use it within MSVC2010.

>see https://cygwin.com/faq.html#faq.programming.msvcrt-and-cygwin

Ok, so I guess my problem is linking against cygwin1.dll *and*
msvcrt.dll together. right?
A. How do I solve that? I assume I should link only against
cygwin1.dll, since I need it for my dll, right?
But how do I prevent Visual Studio to link against msvcrt.dll as well?

B. **OFF-TOPIC**: How can I reply to a specific message in the mailing list?
I'm pretty sure that just mention the same title won't be enough. even
tho that what I'm trying to do right now...
I'm not subscribed to the list, so I can't just hit the "Reply" in my
mail (http gmail).
I've tried to look everywhere, got even for several mailing-list FAQ's
(non-cygwin related), but found nothing.

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

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

* Re: Using DLL compiled with Cygwin inside Visual Studio 2010
  2014-09-14  9:56 Using DLL compiled with Cygwin inside Visual Studio 2010 איציק בק
@ 2014-09-14 10:37 ` Csaba Raduly
  2014-09-14 17:28   ` Andrey Repin
  2014-09-14 23:24 ` Mark Geisert
  1 sibling, 1 reply; 7+ messages in thread
From: Csaba Raduly @ 2014-09-14 10:37 UTC (permalink / raw)
  To: cygwin list

Hi,

On Sun, Sep 14, 2014 at 11:40 AM, איציק בק  wrote:
>
> B. **OFF-TOPIC**: How can I reply to a specific message in the mailing list?
> I'm pretty sure that just mention the same title won't be enough. even
> tho that what I'm trying to do right now...
> I'm not subscribed to the list, so I can't just hit the "Reply" in my
> mail (http gmail).

You could try hitting Reply and manually adding the mailing list
address (c...@c... . com),  or replacing the list of recipients with
it.

Csaba
-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

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

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

* Re: Using DLL compiled with Cygwin inside Visual Studio 2010
  2014-09-14 10:37 ` Csaba Raduly
@ 2014-09-14 17:28   ` Andrey Repin
  2014-09-15 10:23     ` Csaba Raduly
  0 siblings, 1 reply; 7+ messages in thread
From: Andrey Repin @ 2014-09-14 17:28 UTC (permalink / raw)
  To: Csaba Raduly, cygwin

Greetings, Csaba Raduly!

>> B. **OFF-TOPIC**: How can I reply to a specific message in the mailing list?
>> I'm pretty sure that just mention the same title won't be enough. even
>> tho that what I'm trying to do right now...
>> I'm not subscribed to the list, so I can't just hit the "Reply" in my
>> mail (http gmail).

> You could try hitting Reply and manually adding the mailing list
> address (c...@c... . com),  or replacing the list of recipients with
> it.

Reply to what?… He's not subscribed.


--
WBR,
Andrey Repin (anrdaemon@yandex.ru) 14.09.2014, <18:23>

Sorry for my terrible english...

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

* Re: Using DLL compiled with Cygwin inside Visual Studio 2010
  2014-09-14  9:56 Using DLL compiled with Cygwin inside Visual Studio 2010 איציק בק
  2014-09-14 10:37 ` Csaba Raduly
@ 2014-09-14 23:24 ` Mark Geisert
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Geisert @ 2014-09-14 23:24 UTC (permalink / raw)
  To: cygwin

איציק בק writes:
> B. **OFF-TOPIC**: How can I reply to a specific message in the mailing list?
> I'm pretty sure that just mention the same title won't be enough. even
> tho that what I'm trying to do right now...
> I'm not subscribed to the list, so I can't just hit the "Reply" in my
> mail (http gmail).
> I've tried to look everywhere, got even for several mailing-list FAQ's
> (non-cygwin related), but found nothing.

Use a gateway such as http://news.gmane.org.  The main Cygwin mailing list
can be read under gmane.os.cygwin there.  You can followup individual posts
and the subject threading is done correctly.  Works great except for
occasional delays in seeing list traffic show up there.

..mark


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

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

* Re: Using DLL compiled with Cygwin inside Visual Studio 2010
  2014-09-14 17:28   ` Andrey Repin
@ 2014-09-15 10:23     ` Csaba Raduly
  0 siblings, 0 replies; 7+ messages in thread
From: Csaba Raduly @ 2014-09-15 10:23 UTC (permalink / raw)
  To: cygwin list

On Sun, Sep 14, 2014 at 4:23 PM, Andrey Repin  wrote:
> Greetings, Csaba Raduly!
>
>>> B. **OFF-TOPIC**: How can I reply to a specific message in the mailing list?
>>> I'm pretty sure that just mention the same title won't be enough. even
>>> tho that what I'm trying to do right now...
>>> I'm not subscribed to the list, so I can't just hit the "Reply" in my
>>> mail (http gmail).
>
>> You could try hitting Reply and manually adding the mailing list
>> address (c...@c... . com),  or replacing the list of recipients with
>> it.
>
> Reply to what?... He's not subscribed.

To the email I assumed he received. He didn't mention how he got the
message he was trying to reply to.

Csaba
-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

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

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

* Re: Using DLL compiled with Cygwin inside Visual Studio 2010
  2014-09-12 13:50 איציק בק
@ 2014-09-12 15:55 ` pfx
  0 siblings, 0 replies; 7+ messages in thread
From: pfx @ 2014-09-12 15:55 UTC (permalink / raw)
  To: cygwin


Le 12/09/2014 14:21, איציק בק a écrit :
> I've read already tremendous amount of articles, tutorials, and
> instructions about how to solve my problem - but still - no gain. I
> just can't put it into work.
>
> My goal is pretty simple: I want to compile a DLL file using Cygwin
> gcc tool, and then use it within MSVC2010.
see https://cygwin.com/faq.html#faq.programming.msvcrt-and-cygwin


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

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

* Using DLL compiled with Cygwin inside Visual Studio 2010
@ 2014-09-12 13:50 איציק בק
  2014-09-12 15:55 ` pfx
  0 siblings, 1 reply; 7+ messages in thread
From: איציק בק @ 2014-09-12 13:50 UTC (permalink / raw)
  To: cygwin

I've read already tremendous amount of articles, tutorials, and
instructions about how to solve my problem - but still - no gain. I
just can't put it into work.

My goal is pretty simple: I want to compile a DLL file using Cygwin
gcc tool, and then use it within MSVC2010. I'm actually want to do it
with my own DLL code, but as for simplicity - I've tried the very
basic example on Cygwin's site - and failed with that too..

What I've done so far: (Most is taken from Cygwin User's Guide, DLL
section: https://cygwin.com/cygwin-ug-net/dll.html#dll-build)

1. Created mydll.c file as following:

*****     mydll.c  *******

#include <stdio.h>
int hello()    {
  printf ("Hello World!\n");
}
************************

2. Compiled mydll.c into mydll.dll using gcc -c mydll.c and gcc
-shared -o mydll.dll mydll.o

3. Opened an empty Win32 Console project in Visual Studio, with the
following code as test.c (code taken from Oleg's code in here, and
based on this) :

********       CygwinDLLTest.c      ********

#include <windows.h>
typedef int (*PFN_HELLO)();
typedef void (*PFN_CYGWIN_DLL_INIT)();
int main()
{
    PFN_HELLO fnHello;
    HMODULE hLib, h = LoadLibrary(TEXT("cygwin1.dll"));
    PFN_CYGWIN_DLL_INIT init =
(PFN_CYGWIN_DLL_INIT)GetProcAddress(h,"cygwin_dll_init");
    init();
    hLib = LoadLibrary (TEXT("D:\\test\\mydll.dll"));
    fnHello = (PFN_HELLO) GetProcAddress (hLib, "hello");
    return fnHello();
}
********************************************

4. Set the path variable on Windows system to include "Cygwin\bin\" directory.

5. Build & Run.

I ended up with the following exception: 0xc0000005: Access violation
reading location 0x003a0048.

Here is the full MSVC2010 Debug Output:

                                           *********************************
'CygwinDLLTest.exe': Loaded 'C:\Users\xxxx\Documents\Visual Studio
2010\Projects\CygwinDLLTest\Debug\CygwinDLLTest.exe', Symbol loaded.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', cannot
find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', cannot
find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\kernelBase.dll',
cannot find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll',
cannot find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'D:\Cygwin\bin\cygwin1.dll', Binary was
not built with debug information.
cYgFFFFFFFF 6119F510 0cYgstd 0x27a70b d 3'CygwinDLLTest.exe': Loaded
'C:\Windows\SysWOW64\user32.dll', cannot find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', cannot
find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', cannot find
or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', cannot
find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', cannot
find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', cannot
find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', cannot
find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', cannot
find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', cannot
find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll',
cannot find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', cannot
find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', cannot
find or open the PDB file.
'CygwinDLLTest.exe': Loaded 'D:\test\mydll.dll', Binary was not built
with debug information.
First-chance exception at 0x611075a8 in CygwinDLLTest.exe: 0xc0000005:
Access violation reading location 0x003a0048
Unhandled exception at 0x611075a8 in CygwinDLLTest.exe: 0xc0000005:
Access violation reading location 0x003a0048
The program '[784] CygwinDLLTest.exe: Native' has exited with code 0 (0x0).
                                           *********************************

Now, it's important to notice that the problem wasn't loading those
DLL's, as their handlers all got an address different from NULL. The
line in the code that cause the exception, was the call to the hello
func, inside the DLL file.

And before you go and say anything about extern "C" or
__declspec(dllimport/dllexport) - won't help. I've tried all of them
and it didn't help. (although, AFAIK - I'm using Explicit Linking in
terms of MS, orDynamic Loading in terms of UNIX, so
__declspec(dllimport/dllexport) is not necessary).

I'm really hope the problem is not at the stack definition, as lying over here:

"Make sure you have 4K of scratch space at the bottom of your stack"

Because I've no clue how to make this happen on MSVC2010 (and
apparently, neither do Oleg...:)

Now, I know there's a direct reference to my problem in Hans Passant's
words over here - still - I couldn't understand how to solve my
problem.

PS - for whomever wants, this my DLL Dumpbin.exe output:


                                           *********************************
Microsoft (R) COFF/PE Dumper Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.
Dump of file D:\test\mydll.dll
File Type: DLL

  Section contains the following exports for mydll.dll
    00000000 characteristics
                0 time date stamp Thu Jan 01 02:00:00 1970
        0.00 version
           1 ordinal base
           1 number of functions
           1 number of names
    ordinal hint RVA      name
          1    0 00001120 hello
  Summary
        1000 .bss
        1000 .data
        1000 .debug_abbrev
        1000 .debug_aranges
        6000 .debug_info
        1000 .debug_line
        1000 .debug_loc
        1000 .debug_ranges
        1000 .debug_str
        1000 .edata
        1000 .eh_frame
        1000 .idata
        1000 .rdata
        1000 .reloc
        1000 .text
                                           *********************************
Thank you in advance!

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

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

end of thread, other threads:[~2014-09-15 10:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-14  9:56 Using DLL compiled with Cygwin inside Visual Studio 2010 איציק בק
2014-09-14 10:37 ` Csaba Raduly
2014-09-14 17:28   ` Andrey Repin
2014-09-15 10:23     ` Csaba Raduly
2014-09-14 23:24 ` Mark Geisert
  -- strict thread matches above, loose matches on Subject: below --
2014-09-12 13:50 איציק בק
2014-09-12 15:55 ` pfx

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