Subject: Re: Usage of dll created in cygwin in VC++
From: [email-masked] (Andrew Lipnitsky)

22 Jan 1999 18:36:28 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: multipart/mixed;
 boundary="------------2D9B1EB428533349D97B8589"
To: "S. Krishnaprasad" <[email-masked]>,
        [email-masked]

This is a multi-part message in MIME format.
--------------2D9B1EB428533349D97B8589
Content-Type: multipart/alternative;
 boundary="------------5F9685F673F044173EEED2FC"

--------------5F9685F673F044173EEED2FC
Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: 7bit

"S. Krishnaprasad" wrote:

>  I have useddllwrap --export-all mdll.dll mylib.a -L. -lgmp I get the
> DLL file.But when I try to use it in a Visual C++ application it gives
> me a undefined reference to the functionnames defined in this DLL.I
> created a export .DEF file which is as follows LIBRARY
> <dllname>EXPORTS     function1    function2 etc..Then I created a
> import file  .lib using dllwrap --dllname <name.dll> --output-lib
> <libname.lib> This created a .lib file
>
>  This when linked into a Visual C++ application it compiles and links
> properly but whenI try to run this application it just terminates at
> the function call. Can anybody help me.

Yes. In order to link dll you have to get library file. But you have to
use
LIB.exe program from VisualStudio like that
d:\DevStudio\VC\bin\LIB.EXE /DEF:foo.def
After that you will get foo.lib file.

>This when linked into a Visual C++ application it compiles and links
properly but when
>I try to run this application it just terminates at the function call.

Due to program (as well dll) compiled with cygwin using cygwin1.dll
you can not link it with Visual C++ . In order to get rid  cygwin1.dll
you must compile your files with -mno-cygwin option, for example:
gcc -mno-cygwin -c foo.c -o foo.o
gcc -mno-cygwin -c dllinit.c -o dllinit.o
And you must create dll with --target option, for example
dllwrap --target i386-mingw32 -mno-cygwin --dllname foo.dll foo.o
dllinit.o
After that you will get foo.dll file and so you can going to VC.
Note:
At first, you  must have something like dllinit.c file (see attachment).

At second, the algorithm described above is suitable only for C, not for
C++
language.

--------------5F9685F673F044173EEED2FC
Content-Type: text/html; charset=koi8-r
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
&nbsp;
<p>"S. Krishnaprasad" wrote:
<blockquote TYPE=CITE>&nbsp;<font color="#000000"><font size=-1>I have
useddllwrap --export-all mdll.dll mylib.a -L. -lgmp</font></font> <font color="#000000"><font size=-1>I
get the DLL file.But when I try to use it in a Visual C++ application it
gives me a undefined reference to the functionnames defined in this DLL.I
created a export .DEF file which is as follows</font></font> <font color="#000000"><font size=-1>LIBRARY
&lt;dllname>EXPORTS</font></font>&nbsp;<font color="#000000"><font size=-1>&nbsp;&nbsp;&nbsp;
function1&nbsp;&nbsp;&nbsp; function2</font></font> <font color="#000000"><font size=-1>etc..Then
I created a import file&nbsp; .lib using</font></font> <font color="#000000"><font size=-1>dllwrap
--dllname &lt;name.dll> --output-lib &lt;libname.lib></font></font> <font color="#000000"><font size=-1>This
created a .lib file</font></font>
<p>&nbsp;<font color="#000000"><font size=-1>This when linked into a Visual
C++ application it compiles and links properly but whenI try to run this
application it just terminates at the function call.</font></font> 
<font color="#000000"><font size=-1>Can
anybody help me.</font></font></blockquote>
Yes. In order to link dll you have to get library file. But you have to
use
<br>LIB.exe program from VisualStudio like that
<br>d:\DevStudio\VC\bin\LIB.EXE /DEF:foo.def
<br>After that you will get foo.lib file.
<p><font color="#000000"><font size=-1>>This when linked into a Visual
C++ application it compiles and links properly but when</font></font>
<br><font color="#000000"><font size=-1>>I try to run this application
it just terminates at the function call.</font></font>
<p>Due to program (as well dll) compiled with cygwin using cygwin1.dll
<br>you can not link it with Visual C++ . In order to get rid&nbsp; cygwin1.dll
<br>you must compile your files with -mno-cygwin option, for example:
<br>gcc -mno-cygwin -c foo.c -o foo.o
<br>gcc -mno-cygwin -c dllinit.c -o dllinit.o
<br>And you must create dll with --target option, for example
<br>dllwrap --target i386-mingw32 -mno-cygwin --dllname foo.dll foo.o dllinit.o
<br>After that you will get foo.dll file and so you can going to VC.
<br>Note:
<br>At first, you&nbsp; must have something like dllinit.c file (see attachment).
<br>At second, the algorithm described above is suitable only for C, not
for C++
<br>language.
</body>
</html>

--------------5F9685F673F044173EEED2FC--

--------------2D9B1EB428533349D97B8589
Content-Type: application/x-unknown-content-type-cfile;
 name="dllinit.c"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="dllinit.c"

--------------2D9B1EB428533349D97B8589--

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".