public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* I want to use DLL compiled with Cygwin with VC(VS2008).
@ 2011-02-12  2:46 Hosoi
  2011-02-12  2:58 ` Christopher Faylor
  0 siblings, 1 reply; 4+ messages in thread
From: Hosoi @ 2011-02-12  2:46 UTC (permalink / raw)
  To: cygwin

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


Hi.

It wants to compile DLL of a certain open source with Cygwin and to use it with VC. 
Because the compilation doesn't pass, it should be Cygwin in MSYS. 

However, when the one that test DLL was compiled with Cygwin is used with VC, it freezes it with LoadLibrary. 

Please teach the method of using DLL compiled with Cygwin in VC(VS2008). 

[test.c] DLL  source
>===
#include <stdio.h>
#include <windows.h>

#ifdef __cplusplus
extern "C" {
#endif

int WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID
lpReserved )
{
    switch (dwReason) {
    case DLL_PROCESS_ATTACH:
        break;

    case DLL_PROCESS_DETACH:
        break;

    case DLL_THREAD_ATTACH:
        break;

    case DLL_THREAD_DETACH:
        break;
    }
    return TRUE;
}
#ifdef __cplusplus
}
#endif

__declspec(dllexport) int hello( );

int hello()
{
    int i;

    i++;

    return i;
}
>===

[test.def]
>===
EXPORTS
    DllMain@12
    hello
>===

compile
$gcc -c test.c
$gcc -shared -Wl,-dll,--enable-stdcall-fixup -o test.dll test.o test.def

[main.c] VC source
>===
#include "stdafx.h"
#include "windows.h"

#ifdef __cplusplus
extern "C"{
#endif

typedef void (*TFUNC)(void);

int _tmain(int argc, _TCHAR* argv[])
{
    HINSTANCE    hInstDLL;
    TFUNC    DllFunction;

    hInstDLL = LoadLibrary( TEXT( "test.dll" ) );     /* ! FREEZE ! */
    if( hInstDLL == NULL )
    {
        return 0;
    }

    DllFunction = (TFUNC)GetProcAddress( hInstDLL, "hello" );

    DllFunction();

    return 0;
}

#ifdef __cplusplus
}
#endif
>===

$cygcheck -s
Cygwin Configuration Diagnostics
Current System Time: Sat Feb 12 11:42:45 2011

Windows 7 Enterprise Ver 6.1 Build 7600 

Running under WOW64 on AMD64

Path:	C:\cygwin\usr\local\bin
	C:\cygwin\bin
	C:\cygwin\bin
	C:\Windows\system32
	C:\Program Files\Common Files\Microsoft Shared\Windows Live
	C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live
	C:\Program Files (x86)\Network Associates\PGP
	C:\Program Files (x86)\Windows Live\Shared
	C:\Program Files\Windows Imaging\
	C:\Program Files (x86)\QuickTime\QTSystem\

Output from C:\cygwin\bin\id.exe
UID: 1001(Hosoi)     GID: 513(None)
513(None)                 0(root)                   544(Administrators)
545(Users)                1008(HelpLibraryUpdaters) 1000(HomeUsers)

SysDir: C:\Windows\system32
WinDir: C:\Windows

USER = 'Hosoi'
PWD = '/home/Hosi/test'
HOME = '/home/Hosoi'

Use '-r' to scan registry

obcaseinsensitive set to 1

Cygwin installations found in the registry:
  System: Key: 1433fba0701a36ab Path: D:\Users\Hosoi\Documents\MailData (ORPHANED)
  System: Key: c5e39b7a9d22bafb Path: C:\cygwin
  System: Key: ecfa3e1086fe9c61 Path: D:\Users\Takayanagi\Documents\RAD Studio\Projects (ORPHANED)
  System: Key: 42ada21a89e4aeec Path: C:\cygwin\home\Hosoi\opendkim-2.3.0.old (ORPHANED)
  System: Key: 16b04c8a8b31c6cc Path: C:\cygwin\home\Hosoi\opendkim-2.3.0.old\opendkim (ORPHANED)
  System: Key: a8fb4064ab2b92ac Path: C:\Windows (ORPHANED)
  System: Key: 5c47c1dca45fa172 Path: D:\Users\Hosoi\Documents\Visual Studio 2008\Projects\PlugInSDK (ORPHANED)
  System: Key: 8bc27f67bbf54b16 Path: d:\Users\Hosoi\Documents\Visual Studio 2008\Projects\PlugInSDK\BkPGP (ORPHANED)
  System: Key: 8cbedc7cffe1aa17 Path: d:\Users\Hosoi\Documents\Visual Studio 2008\Projects\PlugInSDK\BkPGP (ORPHANED)
  System: Key: a9f79d79ef17f1ad Path: C:\Windows (ORPHANED)
  System: Key: ef5e464c6d4ee1da Path: d:\Users\Hosoi\Documents\Visual Studio 2008\Projects\PlugInSDK\Test (ORPHANED)
  System: Key: b62f536e6722ee46 Path: d:\Users\Hosoi\Documents\Visual Studio 2008\Projects\PlugInSDK\Test2 (ORPHANED)

a:  fd             N/A    N/A                    
c:  hd  NTFS    953766Mb  51% CP CS UN PA FC     
d:  hd  NTFS    953866Mb  28% CP CS UN PA FC     ボリューム
e:  hd  NTFS    476937Mb  38% CP CS UN PA FC     ボリューム
f:  cd             N/A    N/A                    
g:  fd  FAT32     3911Mb  98% CP    UN           EBOOSTR
h:  cd             N/A    N/A                    

C:\cygwin        /          system  binary,auto
C:\cygwin\bin    /usr/bin   system  binary,auto
C:\cygwin\lib    /usr/lib   system  binary,auto
cygdrive prefix  /cygdrive  user    binary,auto

Found: C:\cygwin\bin\awk
Found: C:\cygwin\bin\awk
 -> C:\cygwin\bin\gawk.exe
Found: C:\cygwin\bin\bash.exe
Found: C:\cygwin\bin\bash.exe
Found: C:\cygwin\bin\cat.exe
Found: C:\cygwin\bin\cat.exe
Found: C:\cygwin\bin\cp.exe
Found: C:\cygwin\bin\cp.exe
Found: C:\cygwin\bin\cpp.exe
Found: C:\cygwin\bin\cpp.exe
Found: C:\MinGW32\bin\cpp.exe
 -> C:\cygwin\etc\alternatives\cpp
 -> C:\cygwin\bin\cpp-4.exe
Not Found: crontab
Found: C:\cygwin\bin\find.exe
Found: C:\cygwin\bin\find.exe
Found: C:\Windows\system32\find.exe
Found: C:\cygwin\bin\gcc.exe
Found: C:\cygwin\bin\gcc.exe
Found: C:\MinGW32\bin\gcc.exe
 -> C:\cygwin\etc\alternatives\gcc
 -> C:\cygwin\bin\gcc-4.exe
Found: C:\MinGW32\bin\gdb.exe
Found: C:\cygwin\bin\grep.exe
Found: C:\cygwin\bin\grep.exe
Found: C:\cygwin\bin\kill.exe
Found: C:\cygwin\bin\kill.exe
Found: C:\cygwin\bin\ld.exe
Found: C:\cygwin\bin\ld.exe
Found: C:\MinGW32\bin\ld.exe
Found: C:\cygwin\bin\ls.exe
Found: C:\cygwin\bin\ls.exe
Found: C:\cygwin\bin\make.exe
Found: C:\cygwin\bin\make.exe
Found: C:\cygwin\bin\mv.exe
Found: C:\cygwin\bin\mv.exe
Found: C:\cygwin\bin\patch.exe
Found: C:\cygwin\bin\patch.exe
Found: C:\cygwin\bin\perl.exe
Found: C:\cygwin\bin\perl.exe
Found: C:\cygwin\bin\rm.exe
Found: C:\cygwin\bin\rm.exe
Found: C:\cygwin\bin\sed.exe
Found: C:\cygwin\bin\sed.exe
Not Found: ssh
Found: C:\cygwin\bin\sh.exe
Found: C:\cygwin\bin\sh.exe
Found: C:\cygwin\bin\tar.exe
Found: C:\cygwin\bin\tar.exe
Found: C:\cygwin\bin\test.exe
Found: C:\cygwin\bin\test.exe
Not Found: vi
Not Found: vim

   15k 2009/12/27 C:\cygwin\bin\cygattr-1.dll
   62k 2011/01/12 C:\cygwin\bin\cygbz2-1.dll
   11k 2009/12/23 C:\cygwin\bin\cygcharset-1.dll
  108k 2010/01/05 C:\cygwin\bin\cygcloog-0.dll
    7k 2003/10/19 C:\cygwin\bin\cygcrypt-0.dll
 1147k 2011/02/08 C:\cygwin\bin\cygcrypto-0.9.8.dll
  943k 2007/12/17 C:\cygwin\bin\cygdb-4.5.dll
 1296k 2007/12/17 C:\cygwin\bin\cygdb_cxx-4.5.dll
  118k 2008/05/09 C:\cygwin\bin\cygexpat-1.dll
   24k 2010/08/15 C:\cygwin\bin\cygffi-4.dll
   43k 2010/01/02 C:\cygwin\bin\cygform-10.dll
   40k 2009/03/01 C:\cygwin\bin\cygform-8.dll
   43k 2009/11/20 C:\cygwin\bin\cygform-9.dll
   47k 2010/01/02 C:\cygwin\bin\cygformw-10.dll
   45k 2010/08/15 C:\cygwin\bin\cyggcc_s-1.dll
   19k 2009/02/26 C:\cygwin\bin\cyggdbm-4.dll
    8k 2009/02/26 C:\cygwin\bin\cyggdbm_compat-4.dll
  315k 2009/06/06 C:\cygwin\bin\cyggmp-3.dll
   14k 2009/06/06 C:\cygwin\bin\cyggmpxx-4.dll
   27k 2010/08/15 C:\cygwin\bin\cyggomp-1.dll
   25k 2011/01/26 C:\cygwin\bin\cyghistory7.dll
  360k 2010/08/15 C:\cygwin\bin\cygicons-0.dll
  982k 2009/12/23 C:\cygwin\bin\cygiconv-2.dll
  193k 2010/05/16 C:\cygwin\bin\cygidn-11.dll
   31k 2005/11/20 C:\cygwin\bin\cygintl-3.dll
   31k 2009/04/03 C:\cygwin\bin\cygintl-8.dll
  335k 2009/06/16 C:\cygwin\bin\cygisc-50.dll
  273k 2010/07/01 C:\cygwin\bin\cygisc-60.dll
    5k 2010/08/31 C:\cygwin\bin\cyglsa.dll
    9k 2010/08/31 C:\cygwin\bin\cyglsa64.dll
   30k 2010/09/23 C:\cygwin\bin\cygltdl-7.dll
   88k 2009/06/16 C:\cygwin\bin\cyglwres-50.dll
   65k 2010/07/01 C:\cygwin\bin\cyglwres-60.dll
  125k 2010/04/09 C:\cygwin\bin\cyglzma-1.dll
  103k 2011/02/03 C:\cygwin\bin\cygmagic-1.dll
   25k 2010/01/02 C:\cygwin\bin\cygmenu-10.dll
   21k 2009/03/01 C:\cygwin\bin\cygmenu-8.dll
   25k 2009/11/20 C:\cygwin\bin\cygmenu-9.dll
   25k 2010/01/02 C:\cygwin\bin\cygmenuw-10.dll
   24k 2008/10/30 C:\cygwin\bin\cygminires.dll
  211k 2009/06/06 C:\cygwin\bin\cygmp-3.dll
   64k 2009/11/09 C:\cygwin\bin\cygmpc-1.dll
  269k 2009/06/07 C:\cygwin\bin\cygmpfr-1.dll
   63k 2010/01/02 C:\cygwin\bin\cygncurses++-10.dll
   66k 2009/03/01 C:\cygwin\bin\cygncurses++-8.dll
   63k 2009/11/20 C:\cygwin\bin\cygncurses++-9.dll
   63k 2010/01/02 C:\cygwin\bin\cygncurses++w-10.dll
  195k 2010/01/02 C:\cygwin\bin\cygncurses-10.dll
  237k 2009/03/01 C:\cygwin\bin\cygncurses-8.dll
  198k 2009/11/20 C:\cygwin\bin\cygncurses-9.dll
  244k 2010/01/02 C:\cygwin\bin\cygncursesw-10.dll
   13k 2010/01/02 C:\cygwin\bin\cygpanel-10.dll
   11k 2009/03/01 C:\cygwin\bin\cygpanel-8.dll
   13k 2009/11/20 C:\cygwin\bin\cygpanel-9.dll
   13k 2010/01/02 C:\cygwin\bin\cygpanelw-10.dll
  224k 2010/06/15 C:\cygwin\bin\cygpcre-0.dll
   10k 2010/06/15 C:\cygwin\bin\cygpcreposix-0.dll
 1627k 2010/08/29 C:\cygwin\bin\cygperl5_10.dll
   22k 2002/06/09 C:\cygwin\bin\cygpopt-0.dll
  695k 2009/04/18 C:\cygwin\bin\cygppl-7.dll
 2481k 2009/04/18 C:\cygwin\bin\cygppl_c-2.dll
   18k 2009/04/18 C:\cygwin\bin\cygpwl-4.dll
  164k 2011/01/26 C:\cygwin\bin\cygreadline7.dll
   10k 2009/12/14 C:\cygwin\bin\cygsigsegv-2.dll
  263k 2011/02/08 C:\cygwin\bin\cygssl-0.9.8.dll
   11k 2010/08/15 C:\cygwin\bin\cygssp-0.dll
  773k 2010/08/15 C:\cygwin\bin\cygstdc++-6.dll
   48k 2010/01/02 C:\cygwin\bin\cygtic-10.dll
   48k 2009/11/20 C:\cygwin\bin\cygtic-9.dll
   48k 2010/01/02 C:\cygwin\bin\cygticw-10.dll
 1128k 2010/05/12 C:\cygwin\bin\cygxml2-2.dll
   76k 2010/08/01 C:\cygwin\bin\cygz.dll
 2586k 2010/08/31 C:\cygwin\bin\cygwin1.dll
    Cygwin DLL version info:
        DLL version: 1.7.7
        DLL epoch: 19
        DLL old termios: 5
        DLL malloc env: 28
        Cygwin conv: 181
        API major: 0
        API minor: 230
        Shared data: 5
        DLL identifier: cygwin1
        Mount registry: 3
        Cygwin registry name: Cygwin
        Program options name: Program Options
        Installations name: Installations
        Cygdrive default prefix: 
        Build date: 
        Shared id: cygwin1S5

   15k 2009/12/27 C:\cygwin\bin\cygattr-1.dll
   62k 2011/01/12 C:\cygwin\bin\cygbz2-1.dll
   11k 2009/12/23 C:\cygwin\bin\cygcharset-1.dll
  108k 2010/01/05 C:\cygwin\bin\cygcloog-0.dll
    7k 2003/10/19 C:\cygwin\bin\cygcrypt-0.dll
 1147k 2011/02/08 C:\cygwin\bin\cygcrypto-0.9.8.dll
  943k 2007/12/17 C:\cygwin\bin\cygdb-4.5.dll
 1296k 2007/12/17 C:\cygwin\bin\cygdb_cxx-4.5.dll
  118k 2008/05/09 C:\cygwin\bin\cygexpat-1.dll
   24k 2010/08/15 C:\cygwin\bin\cygffi-4.dll
   43k 2010/01/02 C:\cygwin\bin\cygform-10.dll
   40k 2009/03/01 C:\cygwin\bin\cygform-8.dll
   43k 2009/11/20 C:\cygwin\bin\cygform-9.dll
   47k 2010/01/02 C:\cygwin\bin\cygformw-10.dll
   45k 2010/08/15 C:\cygwin\bin\cyggcc_s-1.dll
   19k 2009/02/26 C:\cygwin\bin\cyggdbm-4.dll
    8k 2009/02/26 C:\cygwin\bin\cyggdbm_compat-4.dll
  315k 2009/06/06 C:\cygwin\bin\cyggmp-3.dll
   14k 2009/06/06 C:\cygwin\bin\cyggmpxx-4.dll
   27k 2010/08/15 C:\cygwin\bin\cyggomp-1.dll
   25k 2011/01/26 C:\cygwin\bin\cyghistory7.dll
  360k 2010/08/15 C:\cygwin\bin\cygicons-0.dll
  982k 2009/12/23 C:\cygwin\bin\cygiconv-2.dll
  193k 2010/05/16 C:\cygwin\bin\cygidn-11.dll
   31k 2005/11/20 C:\cygwin\bin\cygintl-3.dll
   31k 2009/04/03 C:\cygwin\bin\cygintl-8.dll
  335k 2009/06/16 C:\cygwin\bin\cygisc-50.dll
  273k 2010/07/01 C:\cygwin\bin\cygisc-60.dll
    5k 2010/08/31 C:\cygwin\bin\cyglsa.dll
    9k 2010/08/31 C:\cygwin\bin\cyglsa64.dll
   30k 2010/09/23 C:\cygwin\bin\cygltdl-7.dll
   88k 2009/06/16 C:\cygwin\bin\cyglwres-50.dll
   65k 2010/07/01 C:\cygwin\bin\cyglwres-60.dll
  125k 2010/04/09 C:\cygwin\bin\cyglzma-1.dll
  103k 2011/02/03 C:\cygwin\bin\cygmagic-1.dll
   25k 2010/01/02 C:\cygwin\bin\cygmenu-10.dll
   21k 2009/03/01 C:\cygwin\bin\cygmenu-8.dll
   25k 2009/11/20 C:\cygwin\bin\cygmenu-9.dll
   25k 2010/01/02 C:\cygwin\bin\cygmenuw-10.dll
   24k 2008/10/30 C:\cygwin\bin\cygminires.dll
  211k 2009/06/06 C:\cygwin\bin\cygmp-3.dll
   64k 2009/11/09 C:\cygwin\bin\cygmpc-1.dll
  269k 2009/06/07 C:\cygwin\bin\cygmpfr-1.dll
   63k 2010/01/02 C:\cygwin\bin\cygncurses++-10.dll
   66k 2009/03/01 C:\cygwin\bin\cygncurses++-8.dll
   63k 2009/11/20 C:\cygwin\bin\cygncurses++-9.dll
   63k 2010/01/02 C:\cygwin\bin\cygncurses++w-10.dll
  195k 2010/01/02 C:\cygwin\bin\cygncurses-10.dll
  237k 2009/03/01 C:\cygwin\bin\cygncurses-8.dll
  198k 2009/11/20 C:\cygwin\bin\cygncurses-9.dll
  244k 2010/01/02 C:\cygwin\bin\cygncursesw-10.dll
   13k 2010/01/02 C:\cygwin\bin\cygpanel-10.dll
   11k 2009/03/01 C:\cygwin\bin\cygpanel-8.dll
   13k 2009/11/20 C:\cygwin\bin\cygpanel-9.dll
   13k 2010/01/02 C:\cygwin\bin\cygpanelw-10.dll
  224k 2010/06/15 C:\cygwin\bin\cygpcre-0.dll
   10k 2010/06/15 C:\cygwin\bin\cygpcreposix-0.dll
 1627k 2010/08/29 C:\cygwin\bin\cygperl5_10.dll
   22k 2002/06/09 C:\cygwin\bin\cygpopt-0.dll
  695k 2009/04/18 C:\cygwin\bin\cygppl-7.dll
 2481k 2009/04/18 C:\cygwin\bin\cygppl_c-2.dll
   18k 2009/04/18 C:\cygwin\bin\cygpwl-4.dll
  164k 2011/01/26 C:\cygwin\bin\cygreadline7.dll
   10k 2009/12/14 C:\cygwin\bin\cygsigsegv-2.dll
  263k 2011/02/08 C:\cygwin\bin\cygssl-0.9.8.dll
   11k 2010/08/15 C:\cygwin\bin\cygssp-0.dll
  773k 2010/08/15 C:\cygwin\bin\cygstdc++-6.dll
   48k 2010/01/02 C:\cygwin\bin\cygtic-10.dll
   48k 2009/11/20 C:\cygwin\bin\cygtic-9.dll
   48k 2010/01/02 C:\cygwin\bin\cygticw-10.dll
 1128k 2010/05/12 C:\cygwin\bin\cygxml2-2.dll
   76k 2010/08/01 C:\cygwin\bin\cygz.dll
 2586k 2010/08/31 C:\cygwin\bin\cygwin1.dll
    Cygwin DLL version info:
        DLL version: 1.7.7
        DLL epoch: 19
        DLL old termios: 5
        DLL malloc env: 28
        Cygwin conv: 181
        API major: 0
        API minor: 230
        Shared data: 5
        DLL identifier: cygwin1
        Mount registry: 3
        Cygwin registry name: Cygwin
        Program options name: Program Options
        Installations name: Installations
        Cygdrive default prefix: 
        Build date: 
        Shared id: cygwin1S5


Can't find the cygrunsrv utility, skipping services check.


Cygwin Package Information
Package               Version
_update-info-dir      00944-1
alternatives          1.3.30c-10
autoconf              10-1
autoconf2.1           2.13-10
autoconf2.5           2.68-1
automake              4-10
automake1.10          1.10.3-1
automake1.11          1.11.1-1
automake1.4           1.4p6-10
automake1.5           1.5-10
automake1.6           1.6.3-11
automake1.7           1.7.9-10
automake1.8           1.8.5-10
automake1.9           1.9.6-10
base-cygwin           3.0-1
base-files            3.9-3
bash                  4.1.9-2
binutils              2.20.51-2
bzip2                 1.0.6-1
coreutils             8.10-1
crypt                 1.1-1
cygutils              1.4.4-1
cygwin                1.7.7-1
cygwin-doc            1.7-1
dash                  0.5.6.1-2
diffutils             2.9-1
doxygen               1.6.1-2
editrights            1.01-2
file                  5.05-1
findutils             4.5.9-2
flexdll               0.25-1
gawk                  3.1.8-1
gcc                   3.4.4-999
gcc-core              3.4.4-999
gcc-g++               3.4.4-999
gcc-mingw             20040810-1
gcc-mingw-core        20050522-1
gcc-mingw-g++         20050522-1
gcc4-core             4.3.4-3
gettext               0.17-11
grep                  2.6.3-1
groff                 1.20.1-2
gzip                  1.3.12-2
ipc-utils             1.0-1
less                  436-1
libattr1              2.4.43-1
libbz2_1              1.0.6-1
libcharset1           1.13.1-1
libcloog0             0.15.7-1
libdb4.5              4.5.20.2-2
libexpat1             2.0.1-1
libffi4               4.3.4-3
libgcc1               4.3.4-3
libgdbm4              1.8.3-20
libgmp3               4.3.1-3
libgmpxx4             4.3.1-3
libgomp1              4.3.4-3
libiconv              1.13.1-1
libiconv2             1.13.1-1
libidn11              1.18-1
libintl3              0.14.5-1
libintl8              0.17-11
libisc-devel          9.7.1-1
libisc50              9.6.0_p1-1
libisc60              9.7.1-1
libltdl7              2.4-1
liblwres-devel        9.7.1-1
liblwres50            9.6.0_p1-1
liblwres60            9.7.1-1
liblzma1              4.999.9beta-11
libmpc1               0.8-1
libmpfr1              2.4.1-4
libncurses10          5.7-18
libncurses8           5.5-10
libncurses9           5.7-16
libncursesw10         5.7-18
libopenssl098         0.9.8r-1
libpcre0              8.02-1
libpopt0              1.6.4-4
libppl                0.10.2-1
libpthread-stubs      0.2-1
libreadline7          6.1.2-2
libsigsegv2           2.8-1
libssp0               4.3.4-3
libstdc++6            4.3.4-3
libtool               2.4-1
libxml2               2.7.7-1
libxml2-devel         2.7.7-1
login                 1.10-10
m4                    1.4.15-1
make                  3.81-2
man                   1.6f-1
mingw-runtime         3.18-1
mingw64-i686-binutils 2.20.51-2
mingw64-i686-gcc-core 4.5.1-2
mingw64-i686-headers  1.0b_svn3825-2
mingw64-i686-pthreads 20100619-2
mingw64-i686-runtime  1.0b_svn3825-1
minires               1.02-1
nasm                  2.08.02-1
openssl               0.9.8r-1
openssl-devel         0.9.8r-1
patch                 2.5.8-9
perl                  5.10.1-5
rebase                3.0.1-1
run                   1.1.13-1
sed                   4.2.1-1
tar                   1.25-1
terminfo              5.7_20091114-14
terminfo0             5.5_20061104-12
texinfo               4.13-3
tzcode                2010j-1
w32api                3.15-1
wget                  1.12-1
which                 2.20-2
xz                    4.999.9beta-11
zlib                  1.2.5-1
zlib-devel            1.2.5-1
zlib0                 1.2.5-1
Use -h to see help about each section

-- 
Y.Hosoi

[-- Attachment #2: Type: text/plain, Size: 137 bytes --]

AntiVir MailGuard によってスキャンされました  v10.0.1.38 AVE 8.2.4.166 VDF 7.11.3.50

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

--
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] 4+ messages in thread

* Re: I want to use DLL compiled with Cygwin with VC(VS2008).
  2011-02-12  2:46 I want to use DLL compiled with Cygwin with VC(VS2008) Hosoi
@ 2011-02-12  2:58 ` Christopher Faylor
  2011-02-14  4:03   ` Re[2]: " Y.Hosoi
  0 siblings, 1 reply; 4+ messages in thread
From: Christopher Faylor @ 2011-02-12  2:58 UTC (permalink / raw)
  To: cygwin

On Sat, Feb 12, 2011 at 11:46:47AM +0900, Hosoi wrote:
>It wants to compile DLL of a certain open source with Cygwin and to use
>it with VC.  Because the compilation doesn't pass, it should be Cygwin
>in MSYS.
>
>However, when the one that test DLL was compiled with Cygwin is used
>with VC, it freezes it with LoadLibrary.
>
>Please teach the method of using DLL compiled with Cygwin in
>VC(VS2008).

You really can't use Cygwin via LoadLibrary without quite a bit of
extra work.

However: http://www.cygwin.com/faq/faq.programming.html#faq.programming.msvs-mingw

cgf

--
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] 4+ messages in thread

* Re[2]: I want to use DLL compiled with Cygwin with VC(VS2008).
  2011-02-12  2:58 ` Christopher Faylor
@ 2011-02-14  4:03   ` Y.Hosoi
  2011-02-19  9:40     ` Jason Curl
  0 siblings, 1 reply; 4+ messages in thread
From: Y.Hosoi @ 2011-02-14  4:03 UTC (permalink / raw)
  To: cygwin

Thank you. 

However, it did not move well. 

If test.dll is done in LoadLibrary, Access Violation is generated. 

Are you still amused something?


[main source code]

#include "stdafx.h"
#include "windows.h"

#ifdef __cplusplus
extern "C"{
#endif

typedef int (*TFUNC)(void);

typedef void (*Tinit)(void);

int _tmain(int argc, _TCHAR* argv[])
{
	int i;

	HINSTANCE	h;
    	HINSTANCE	hInstDLL;

	Tinit		init;
	TFUNC		DllFunction;
	DWORD		ErrNo;

	h = LoadLibrary( TEXT( "cygwin1.dll" ) );
	init = (Tinit)GetProcAddress( h, "cygwin_dll_init" );

	init();

	hInstDLL = LoadLibrary( TEXT( "test.dll" ) );		/* !Access Violation! */
	if( hInstDLL == NULL )
	{
		ErrNo = GetLastError();
		return 0;
	}
	DllFunction = (TFUNC)GetProcAddress( hInstDLL, "hello" );
	i = DllFunction();

	FreeLibrary( hInstDLL );
	FreeLibrary( h );

	return 0;
}

#ifdef __cplusplus
}
#endif

-- 
 Y.Hosoi <mlist@mail.cuvie.net>


--
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] 4+ messages in thread

* Re: I want to use DLL compiled with Cygwin with VC(VS2008).
  2011-02-14  4:03   ` Re[2]: " Y.Hosoi
@ 2011-02-19  9:40     ` Jason Curl
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Curl @ 2011-02-19  9:40 UTC (permalink / raw)
  To: cygwin

On 14/02/2011 05:03, Y.Hosoi wrote:
> Thank you.
>
> However, it did not move well.
>
> If test.dll is done in LoadLibrary, Access Violation is generated.
>
> Are you still amused something?
>
>
> [main source code]
>
> #include "stdafx.h"
> #include "windows.h"
>
> #ifdef __cplusplus
> extern "C"{
> #endif
>
> typedef int (*TFUNC)(void);
>
> typedef void (*Tinit)(void);
>
> int _tmain(int argc, _TCHAR* argv[])
> {
> 	int i;
>
> 	HINSTANCE	h;
>      	HINSTANCE	hInstDLL;
>
> 	Tinit		init;
> 	TFUNC		DllFunction;
> 	DWORD		ErrNo;
>
> 	h = LoadLibrary( TEXT( "cygwin1.dll" ) );
> 	init = (Tinit)GetProcAddress( h, "cygwin_dll_init" );
>
> 	init();
>
> 	hInstDLL = LoadLibrary( TEXT( "test.dll" ) );		/* !Access Violation! */
> 	if( hInstDLL == NULL )
> 	{
> 		ErrNo = GetLastError();
> 		return 0;
> 	}
> 	DllFunction = (TFUNC)GetProcAddress( hInstDLL, "hello" );
> 	i = DllFunction();
>
> 	FreeLibrary( hInstDLL );
> 	FreeLibrary( h );
>
> 	return 0;
> }
>
> #ifdef __cplusplus
> }
> #endif
>

Try the following code. This was pulled from the Cygwin sources. There 
is a test case that does exactly this, loads cygwin1.dll dynamically. 
You need to make sure you allocate stack. This was compiled with MINGW. 
This is part of a larger program, so it might need some adjustments. The 
function cygloadCRTStartup() is pretty much from the sources.

Note that the entry point needs to be set with the linker option:
-Wl,-entry -Wl,_cygloadCRTStartup@0

#include <windows.h>
#include <stdio.h>
#include "getopt.h"

#define CYGHELP_SUCCESS           EXIT_SUCCESS
#define CYGHELP_ARG_ERROR         1
#define CYGHELP_DLL_NOT_FOUND     100
#define CYGHELP_DLL_NOT_SUPPORTED 101
#define CYGHELP_INTERNAL_ERROR    255

typedef void    (__cdecl cdi_t)(void);
typedef void    (__cdecl cctfwp_t)(const char *path, char *win32path);
typedef void    (__cdecl cctfpp_t)(const char *path, char *posixpath);

int mainCRTStartup ();

int __stdcall cygloadCRTStartup ()
{
	char   padding[32768];
	size_t delta;
	int    result;
	char   block[32768];
	char  *stackbase;
	char  *_stackbase;
	char  *_end;

	_end = padding + sizeof(padding);
#ifdef __GNUC__
	__asm__ (
		"movl %%fs:4, %0"
		:"=r"(stackbase)
     );
#else
	__asm {
		mov eax, fs:[4];
		mov stackbase, eax;
	}
#endif
	_stackbase = stackbase;

	// We've gotten as close as we can to the top of the stack.  Even
	// subverting the entry point, though, still doesn't get us there-- I'm
	// getting 64 bytes in use before the entry point.  So we back up the data
	// there and restore it when the destructor is called:
	if ((_stackbase - _end) != 0) {
		delta = (_stackbase - _end);
		memcpy (block, _end, delta);
     }
	result = mainCRTStartup ();
	memcpy(_end, block, delta);
	return result;
}

int main(int argc, char **argv)
{
	HMODULE     cygwinDll;
	DWORD       winres;
	cdi_t      *cygwin_dll_init;
	cctfwp_t   *cygwin_conv_to_full_win32_path;
	cctfpp_t   *cygwin_conv_to_full_posix_path;
	const char *dll = "cygwin1.dll";
	const char *ppath = NULL;
	const char *wpath = NULL;
	
	char        module[MAX_PATH];
	char        buff[MAX_PATH];
	int         i;
	int         c;
	
	// Get any options the user provides
	opterr = 0;
	while ((c = getopt(argc, argv, "c:p:w:")) != -1) {
		switch (c) {
		case 'c':
			dll = optarg;
			break;
		case 'p':
			ppath = optarg;
			break;
		case 'w':
			wpath = optarg;
			break;
		case '?':
			if (optopt == 'c') {
				fprintf(stderr, "Option -%c requires the full name for the Cygwin 
DLL\n", optopt);
			} else if (optopt == 'p') {
				fprintf(stderr, "Option -%c requires the Posix path to convert\n", 
optopt);
			} else if (optopt == 'w') {
				fprintf(stderr, "Option -%c requires the Windows path to convert\n", 
optopt);
			} else {
				fprintf(stderr, "Unknown option -%c\n", optopt);
			}
			return CYGHELP_ARG_ERROR;
		default:
			fprintf(stderr, "Argument %c given, unknown handler\n", c);
			return CYGHELP_INTERNAL_ERROR;
		}
	}

	// Load the library and determine the full path to the library (as
	// determined by windows)
	cygwinDll = LoadLibrary(dll);
	if (!cygwinDll) {
		fprintf(stderr, "Couldn't find %s\n", dll);
		return CYGHELP_DLL_NOT_FOUND;
	}
	winres = GetModuleFileName(cygwinDll, module, MAX_PATH);
	if (!winres) {
		winres = GetLastError();
		fprintf(stderr, "GetModuleFilename returned error %d\n", winres);
		return CYGHELP_DLL_NOT_SUPPORTED;
	}
	
	cygwin_dll_init = (cdi_t *)
		GetProcAddress(cygwinDll, "cygwin_dll_init");
	if (!cygwin_dll_init) {
		fprintf(stderr, "Couldn't find cygwin_dll_init\n");
		return CYGHELP_DLL_NOT_SUPPORTED;
	}
	
	cygwin_conv_to_full_win32_path = (cctfwp_t *)
		GetProcAddress(cygwinDll, "cygwin_conv_to_full_win32_path");
	if (!cygwin_conv_to_full_win32_path) {
		fprintf(stderr, "Couldn't find cygwin_conv_to_full_win32_path\n");
		return CYGHELP_DLL_NOT_SUPPORTED;
	}
	
	cygwin_conv_to_full_posix_path = (cctfpp_t *)
		GetProcAddress(cygwinDll, "cygwin_conv_to_full_posix_path");
	if (!cygwin_conv_to_full_posix_path) {
		fprintf(stderr, "Couldn't find cygwin_conv_to_full_posix_path\n");
		return CYGHELP_DLL_NOT_SUPPORTED;
	}
	
	// Initialise the library. The first line is always the name of the
	// module. Then we print the result that the user expects. This allows
	// programs to know what library is in use and to easily parse the output
	// for their needs
	cygwin_dll_init();
	printf("%s\n", module);
	if (ppath) {
		cygwin_conv_to_full_win32_path(ppath, buff);
		printf("%s\n", buff);
	}
	if (wpath) {
		cygwin_conv_to_full_posix_path(wpath, buff);
		printf("%s\n", buff);
	}
	
	// We've finished now, so let's exit
	FreeLibrary(cygwinDll);
	return CYGHELP_SUCCESS;
}


--
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] 4+ messages in thread

end of thread, other threads:[~2011-02-19  9:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-12  2:46 I want to use DLL compiled with Cygwin with VC(VS2008) Hosoi
2011-02-12  2:58 ` Christopher Faylor
2011-02-14  4:03   ` Re[2]: " Y.Hosoi
2011-02-19  9:40     ` Jason Curl

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